diff --git a/CMakeLists.txt b/CMakeLists.txt index 2fd6b3f..0dd5105 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 4.0.0) +cmake_minimum_required(VERSION 3.12) project(libucore C) execute_process(COMMAND git -C ${CMAKE_SOURCE_DIR} describe --abbrev=5 --dirty --always OUTPUT_VARIABLE version_revision WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_STRIP_TRAILING_WHITESPACE) @@ -28,6 +28,12 @@ if (BUILD_SANITIZE) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") endif() +if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE) + # Set the property for multi-config generators as well, if applicable + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release RelWithDebInfo MinSizeRel) +endif() + include_directories(include) add_subdirectory(src) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 6b3e795..6e9f79b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,14 +1,15 @@ file(GLOB TEST_SOURCE_FILES test_*.c) +link_libraries(check ucore Threads::Threads) if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") include_directories("/opt/homebrew/include") link_directories("/opt/homebrew/lib") list(REMOVE_ITEM TEST_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/test_ringbuf.c) else() - target_link_libraries(rt) + link_libraries(rt) endif() + add_executable(test_runner ${TEST_SOURCE_FILES}) -target_link_libraries(test_runner check ucore PRIVATE Threads::Threads) add_custom_target(test COMMAND test_runner DEPENDS test_runner