diff options
author | Jan200101 <sentrycraft123@gmail.com> | 2021-08-08 11:20:35 +0200 |
---|---|---|
committer | Jan200101 <sentrycraft123@gmail.com> | 2021-08-08 11:20:35 +0200 |
commit | 34290dfd1377a410b3fea96eb855fd4325a2c269 (patch) | |
tree | 13587e72351b2db83853090d6bb35051f64e4116 | |
parent | 7d2c186d9ba3bd6438ae4afab349b8c0c795cef6 (diff) | |
download | polecat-34290dfd1377a410b3fea96eb855fd4325a2c269.tar.gz polecat-34290dfd1377a410b3fea96eb855fd4325a2c269.zip |
replace static core library to be an object library
-rw-r--r-- | src/CMakeLists.txt | 29 | ||||
-rw-r--r-- | src/command.h | 2 | ||||
-rw-r--r-- | src/mock/CMakeLists.txt | 3 |
3 files changed, 13 insertions, 21 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8b36820..b982b32 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,6 @@ set(C_STANDARD 99) -set(LIBSOURCES +set(MAINSOURCES ${CMAKE_CURRENT_SOURCE_DIR}/command.h ${CMAKE_CURRENT_SOURCE_DIR}/common.c ${CMAKE_CURRENT_SOURCE_DIR}/common.h @@ -23,15 +23,9 @@ set(LIBSOURCES ${CMAKE_CURRENT_SOURCE_DIR}/tar.h ) -FILE(WRITE ${CMAKE_BINARY_DIR}/base.c "extern int empty;\n") - -set(MAINSOURCES - ${CMAKE_BINARY_DIR}/base.c -) - if (NOT WIN32) -set(LIBSOURCES - ${LIBSOURCES} +set(MAINSOURCES + ${MAINSOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/wine.c ${CMAKE_CURRENT_SOURCE_DIR}/wine.h ) @@ -52,21 +46,20 @@ set(CFLAGS ${LIBCURL_CFLAGS} ) -add_library(${CMAKE_PROJECT_NAME}core STATIC ${LIBSOURCES}) -add_executable(${CMAKE_PROJECT_NAME} ${MAINSOURCES}) +add_library(core OBJECT ${MAINSOURCES}) + +target_include_directories(core PUBLIC ${JSONC_INCLUDE_DIRS}) +target_include_directories(core PUBLIC ${LIBARCHIVE_INCLUDE_DIRS}) +target_include_directories(core PUBLIC ${LIBCURL_INCLUDE_DIRS}) -target_include_directories(${CMAKE_PROJECT_NAME}core PUBLIC ${JSONC_INCLUDE_DIRS}) -target_include_directories(${CMAKE_PROJECT_NAME}core PUBLIC ${LIBARCHIVE_INCLUDE_DIRS}) -target_include_directories(${CMAKE_PROJECT_NAME}core PUBLIC ${LIBCURL_INCLUDE_DIRS}) +target_compile_options(core PUBLIC ${CFLAGS}) + +add_executable(${CMAKE_PROJECT_NAME} $<TARGET_OBJECTS:core>) -target_link_libraries(${CMAKE_PROJECT_NAME} LINK_PUBLIC ${CMAKE_PROJECT_NAME}core) target_link_libraries(${CMAKE_PROJECT_NAME} LINK_PUBLIC ${JSONC_LIBRARIES}) target_link_libraries(${CMAKE_PROJECT_NAME} LINK_PUBLIC ${LIBARCHIVE_LIBRARIES}) target_link_libraries(${CMAKE_PROJECT_NAME} LINK_PUBLIC ${LIBCURL_LIBRARIES}) -target_compile_options(${CMAKE_PROJECT_NAME}core PUBLIC ${CFLAGS}) -target_compile_options(${CMAKE_PROJECT_NAME} PUBLIC ${CFLAGS}) - install(TARGETS ${CMAKE_PROJECT_NAME}) if(BUILD_MOCK) diff --git a/src/command.h b/src/command.h index 5db65cf..8a7c101 100644 --- a/src/command.h +++ b/src/command.h @@ -30,7 +30,7 @@ { \ fprintf(stderr, USAGE_STR MSG " <command>\n"); \ print_help(GROUP##_commands, ARRAY_LEN(GROUP##_commands), GROUP##_flags, ARRAY_LEN(GROUP##_flags)); \ - return EXIT_FAILURE; \ + return EXIT_SUCCESS; \ } /* diff --git a/src/mock/CMakeLists.txt b/src/mock/CMakeLists.txt index 320e8a9..8c705e4 100644 --- a/src/mock/CMakeLists.txt +++ b/src/mock/CMakeLists.txt @@ -35,9 +35,8 @@ add_dependencies(mock wine_tar wine_json) target_include_directories(mock PRIVATE ${WINE_TAR_DIR} ${CMAKE_CURRENT_BINARY_DIR}) set(NAME ${CMAKE_PROJECT_NAME}_mock) -add_executable(${NAME} ${MAINSOURCES}) +add_executable(${NAME} $<TARGET_OBJECTS:core>) -target_link_libraries(${NAME} LINK_PUBLIC ${CMAKE_PROJECT_NAME}core) target_link_libraries(${NAME} LINK_PUBLIC ${JSONC_LIBRARIES}) target_link_libraries(${NAME} LINK_PUBLIC ${LIBARCHIVE_LIBRARIES}) target_link_libraries(${NAME} LINK_PUBLIC mock) |