diff options
author | gramanas <anastasis.gramm2@gmail.com> | 2018-09-27 12:36:54 +0300 |
---|---|---|
committer | gramanas <anastasis.gramm2@gmail.com> | 2018-09-27 12:36:54 +0300 |
commit | 03917439a1ddcf202e9fc53937b10eeb7ec0a99a (patch) | |
tree | d45b75be65d08be774058d67fda94bc7665bdce9 /CMakeLists.txt | |
parent | 7286c9fc5b55df0499c7a8f28b5e61ec57e788cc (diff) | |
download | ck-03917439a1ddcf202e9fc53937b10eeb7ec0a99a.tar.gz ck-03917439a1ddcf202e9fc53937b10eeb7ec0a99a.tar.bz2 ck-03917439a1ddcf202e9fc53937b10eeb7ec0a99a.zip |
Update CMakeLists and build istructions
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ff55a80..1228e82 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,21 +14,20 @@ project(ck C) set(ck_MAJOR_VERSION 0) set(ck_MINOR_VERSION 4) -# compiler -set(CMAKE_C_COMPILER clang) - -# compiler flags - # options option(CK_ASAN "Build with asan") -option(CK_RELEASE "Release build") +option(CK_DEBUG "Build with debug symbols") +option(CK_TESTS "Make the tests") +option(CK_SHARED "Build with shared lib") if(CK_ASAN) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") endif() -if (NOT CK_RELEASE) +if (CK_DEBUG) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3") +else(CK_DEBUG) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3") endif() # Set project directories @@ -79,26 +78,36 @@ include_directories(${PROJECT_BINARY_DIR}) include_directories(${CMAKE_BINARY_DIR}) include_directories(${SQLITE3_INCLUDE_DIRS}) -# Create the shared library -add_library (ckLib SHARED +# Create the library (static by default) +if (CK_SHARED) + add_library (ckLib SHARED + ${ckLib_src} + ${ckLib_hdr} + ) +else(CK_SHARED) + add_library (ckLib STATIC ${ckLib_src} ${ckLib_hdr} -) + ) +endif() # Link add_executable(ck ${ckBin_src}) target_link_libraries(ck ckLib) target_link_libraries(ck ${SQLITE3_LIBRARIES}) -## unit test -add_executable(ck-test ${ckUnitTest_src}) -target_link_libraries(ck-test ckLib) -target_link_libraries(ck-test ${SQLITE3_LIBRARIES}) -# copy test files -set(BIN_TESTS_DIR ${CMAKE_BINARY_DIR}/res/tests) -set(PROJECT_TESTING_GROUNDS ${CMAKE_BINARY_DIR}/test_files) -configure_file(${TESTS_DIR}/init ${BIN_TESTS_DIR}/init @ONLY) -configure_file(${TESTS_DIR}/add ${BIN_TESTS_DIR}/add @ONLY) -configure_file(${TESTS_DIR}/list ${BIN_TESTS_DIR}/list @ONLY) -# check_ck -configure_file(${RES_DIR}/check_ck check_ck @ONLY) +if (CK_TESTS) + ## unit test + add_executable(ck-test ${ckUnitTest_src}) + target_link_libraries(ck-test ckLib) + target_link_libraries(ck-test ${SQLITE3_LIBRARIES}) + + # copy test files + set(BIN_TESTS_DIR ${CMAKE_BINARY_DIR}/res/tests) + set(PROJECT_TESTING_GROUNDS ${CMAKE_BINARY_DIR}/test_files) + configure_file(${TESTS_DIR}/init ${BIN_TESTS_DIR}/init @ONLY) + configure_file(${TESTS_DIR}/add ${BIN_TESTS_DIR}/add @ONLY) + configure_file(${TESTS_DIR}/list ${BIN_TESTS_DIR}/list @ONLY) + # check_ck + configure_file(${RES_DIR}/check_ck check_ck @ONLY) +endif() |