diff options
author | Jan200101 <sentrycraft123@gmail.com> | 2021-07-22 22:46:50 +0200 |
---|---|---|
committer | Jan200101 <sentrycraft123@gmail.com> | 2021-07-22 22:46:50 +0200 |
commit | 9e5f89f6a2a4a05e7dd92a7197cf24024eac8346 (patch) | |
tree | 0fb26f7fc65f2ef3fbc0864f2bc27ec54b5970e6 | |
parent | fa579dfd846d50bcd2edd28277036b2fb298c643 (diff) | |
download | polecat-9e5f89f6a2a4a05e7dd92a7197cf24024eac8346.tar.gz polecat-9e5f89f6a2a4a05e7dd92a7197cf24024eac8346.zip |
compile core files into a static library to link against
-rw-r--r-- | src/CMakeLists.txt | 43 | ||||
-rw-r--r-- | src/mock/CMakeLists.txt | 7 |
2 files changed, 26 insertions, 24 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e2eef6c..95e6b6b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,6 @@ set(C_STANDARD 99) -set(SOURCES +set(LIBSOURCES ${CMAKE_CURRENT_SOURCE_DIR}/command.h ${CMAKE_CURRENT_SOURCE_DIR}/common.c ${CMAKE_CURRENT_SOURCE_DIR}/common.h @@ -15,37 +15,25 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/lutris/keyword.h ${CMAKE_CURRENT_SOURCE_DIR}/lutris/runner.h ${CMAKE_CURRENT_SOURCE_DIR}/lutris/task.h - ${CMAKE_CURRENT_SOURCE_DIR}/main.c - ${CMAKE_CURRENT_SOURCE_DIR}/main.h ${CMAKE_CURRENT_SOURCE_DIR}/net.c ${CMAKE_CURRENT_SOURCE_DIR}/net.h ${CMAKE_CURRENT_SOURCE_DIR}/tar.c ${CMAKE_CURRENT_SOURCE_DIR}/tar.h ) +set(MAINSOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/main.c + ${CMAKE_CURRENT_SOURCE_DIR}/main.h +) if (NOT WIN32) -set(SOURCES - ${SOURCES} +set(MAINSOURCES + ${MAINSOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/wine.c ${CMAKE_CURRENT_SOURCE_DIR}/wine.h ) endif() -find_package(Libcurl REQUIRED) -find_package(JsonC REQUIRED) -find_package(Libarchive REQUIRED) - -add_executable(${CMAKE_PROJECT_NAME} ${SOURCES}) - -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_include_directories(${CMAKE_PROJECT_NAME} PUBLIC ${JSONC_INCLUDE_DIRS}) -target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC ${LIBARCHIVE_INCLUDE_DIRS}) -target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC ${LIBCURL_INCLUDE_DIRS}) - set(CFLAGS -Wall -Wextra -pedantic -Wconversion -Wshadow -Wstrict-aliasing @@ -57,6 +45,23 @@ set(CFLAGS ${LIBCURL_CFLAGS} ) +find_package(Libcurl REQUIRED) +find_package(JsonC REQUIRED) +find_package(Libarchive REQUIRED) + +add_library(${CMAKE_PROJECT_NAME}core STATIC ${LIBSOURCES}) +add_executable(${CMAKE_PROJECT_NAME} ${MAINSOURCES}) + +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_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_link_libraries(${CMAKE_PROJECT_NAME} LINK_PUBLIC ${CMAKE_PROJECT_NAME}core) + +target_compile_options(${CMAKE_PROJECT_NAME}core PUBLIC ${CFLAGS}) target_compile_options(${CMAKE_PROJECT_NAME} PUBLIC ${CFLAGS}) install(TARGETS ${CMAKE_PROJECT_NAME}) diff --git a/src/mock/CMakeLists.txt b/src/mock/CMakeLists.txt index a45d88e..7f4f471 100644 --- a/src/mock/CMakeLists.txt +++ b/src/mock/CMakeLists.txt @@ -35,14 +35,11 @@ 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} ${SOURCES}) +add_executable(${NAME} ${MAINSOURCES}) target_link_libraries(${NAME} LINK_PUBLIC ${JSONC_LIBRARIES}) target_link_libraries(${NAME} LINK_PUBLIC ${LIBARCHIVE_LIBRARIES}) +target_link_libraries(${NAME} LINK_PUBLIC ${CMAKE_PROJECT_NAME}core) target_link_libraries(${NAME} LINK_PUBLIC mock) -target_include_directories(${NAME} PUBLIC ${JSONC_INCLUDE_DIRS}) -target_include_directories(${NAME} PUBLIC ${LIBARCHIVE_INCLUDE_DIRS}) -target_include_directories(${NAME} PUBLIC ${LIBCURL_INCLUDE_DIRS}) - target_compile_options(${NAME} PUBLIC ${CFLAGS}) |