From: Roger Shimizu Date: Fri, 27 Aug 2021 22:30:10 +0900 Subject: autopkgtest: Use system library to run test This is for debian autopkgtest, or CI pipeline. We don't need to build the library, and only build tests. And while building the tests, we link with system libcork16, not the local one, which is not built at all. --- CMakeLists.txt | 2 ++ cmake/FindCTargets.cmake | 14 -------------- src/CMakeLists.txt | 50 +++--------------------------------------------- tests/CMakeLists.txt | 4 +--- 4 files changed, 6 insertions(+), 64 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d2776e..d44cada 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,6 +79,8 @@ set(THREADS_LDFLAGS "${CMAKE_THREAD_LIBS_INIT}") set(THREADS_STATIC_LDFLAGS "${CMAKE_THREAD_LIBS_INIT}") set(PTHREAD_LIBS "${CMAKE_THREAD_LIBS_INIT}") +pkgconfig_prereq(libcork) + #----------------------------------------------------------------------- # Include our subdirectories diff --git a/cmake/FindCTargets.cmake b/cmake/FindCTargets.cmake index 4461065..5632ddc 100644 --- a/cmake/FindCTargets.cmake +++ b/cmake/FindCTargets.cmake @@ -175,19 +175,6 @@ function(add_c_executable __TARGET_NAME) add_executable(${__TARGET_NAME} ${__SOURCES}) - if (CMAKE_VERSION VERSION_GREATER "2.8.11") - target_include_directories( - ${__TARGET_NAME} PUBLIC - ${CMAKE_SOURCE_DIR}/include - ${CMAKE_BINARY_DIR}/include - ) - else (CMAKE_VERSION VERSION_GREATER "2.8.11") - include_directories( - ${CMAKE_SOURCE_DIR}/include - ${CMAKE_BINARY_DIR}/include - ) - endif (CMAKE_VERSION VERSION_GREATER "2.8.11") - if (ENABLE_SHARED_EXECUTABLES) target_add_shared_libraries( ${__TARGET_NAME} @@ -221,7 +208,6 @@ function(add_c_test TEST_NAME) OUTPUT_NAME ${TEST_NAME} SOURCES ${TEST_NAME}.c LIBRARIES check - LOCAL_LIBRARIES ${ALL_LOCAL_LIBRARIES} ) add_test(${TEST_NAME} ${TEST_NAME}) endfunction(add_c_test) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6124800..23a5a0c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -34,50 +34,6 @@ # # [1] http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html#Updating-version-info -add_c_library( - libcork - OUTPUT_NAME cork - PKGCONFIG_NAME libcork - VERSION_INFO 17:0:1 - SOURCES - libcork/cli/commands.c - libcork/core/allocator.c - libcork/core/error.c - libcork/core/gc.c - libcork/core/hash.c - libcork/core/id.c - libcork/core/ip-address.c - libcork/core/mempool.c - libcork/core/timestamp.c - libcork/core/u128.c - libcork/core/version.c - libcork/ds/array.c - libcork/ds/bitset.c - libcork/ds/buffer.c - libcork/ds/dllist.c - libcork/ds/file-stream.c - libcork/ds/hash-table.c - libcork/ds/managed-buffer.c - libcork/ds/ring-buffer.c - libcork/ds/slice.c - libcork/ds/stream.c - libcork/posix/directory-walker.c - libcork/posix/env.c - libcork/posix/exec.c - libcork/posix/files.c - libcork/posix/process.c - libcork/posix/subprocess.c - libcork/pthreads/thread.c - LIBRARIES - threads -) - -if (ENABLE_SHARED OR ENABLE_SHARED_EXECUTABLES OR ENABLE_SHARED_TESTS) - set_target_properties(libcork-shared PROPERTIES - COMPILE_DEFINITIONS CORK_API=CORK_EXPORT - ) -endif (ENABLE_SHARED OR ENABLE_SHARED_EXECUTABLES OR ENABLE_SHARED_TESTS) - if (ENABLE_STATIC OR NOT ENABLE_SHARED_EXECUTABLES OR NOT ENABLE_SHARED_TESTS) set_target_properties(libcork-static PROPERTIES COMPILE_DEFINITIONS CORK_API=CORK_LOCAL @@ -92,7 +48,7 @@ add_c_executable( cork-hash OUTPUT_NAME cork-hash SOURCES cork-hash/cork-hash.c - LOCAL_LIBRARIES + LIBRARIES libcork ) @@ -104,7 +60,7 @@ add_c_executable( cork-initializer/init1.c cork-initializer/init2.c cork-initializer/main.c - LOCAL_LIBRARIES + LIBRARIES libcork ) @@ -113,6 +69,6 @@ add_c_executable( SKIP_INSTALL OUTPUT_NAME cork-test SOURCES cork-test/cork-test.c - LOCAL_LIBRARIES + LIBRARIES libcork ) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 69abeaa..957d705 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -7,8 +7,6 @@ # ---------------------------------------------------------------------- include_directories( - ${CMAKE_SOURCE_DIR}/include - ${CMAKE_BINARY_DIR}/include ${CMAKE_CURRENT_BINARY_DIR} ) @@ -21,7 +19,7 @@ macro(make_test test_name) add_executable(${test_name} ${test_name}.c) add_test(${test_name} ${test_name}) if (ENABLE_SHARED_TESTS) - target_link_libraries(${test_name} ${CHECK_LIBRARIES} libcork-shared) + target_link_libraries(${test_name} ${CHECK_LIBRARIES} ${THREADS_LDFLAGS} cork) else (ENABLE_SHARED_TESTS) set_target_properties(${test_name} PROPERTIES COMPILE_DEFINITIONS CORK_EMBEDDED_TEST=1) target_link_libraries(${test_name} ${CHECK_LIBRARIES} libcork-static)