aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt29
-rw-r--r--src/command.h2
-rw-r--r--src/mock/CMakeLists.txt3
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)