diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ea8355..1355605 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 3.14) project( sgc - VERSION 0.0.1 - DESCRIPTION "Static split parser" + VERSION 1.0.0 + DESCRIPTION "generic algorithms and data structures" HOMEPAGE_URL "https://github.com/red0124/sgc" LANGUAGES C ) @@ -11,9 +11,9 @@ project( # ---- Warning guard ---- # Protect dependents from this project's warnings if the guard isn't disabled -set(sgc_warning_guard SYSTEM) +set(SGC_WARNING_GUARD SYSTEM) if(sgc_INCLUDE_WITHOUT_SYSTEM) - set(sgc_warning_guard "") + set(SGC_WARNING_GUARD "") endif() # ---- Declare library ---- @@ -23,36 +23,32 @@ add_library(sgc::sgc ALIAS sgc) target_include_directories( sgc - ${sgc_warning_guard} - INTERFACE - "$" + ${SGC_WARNING_GUARD} + INTERFACE "$" ) target_compile_features(sgc INTERFACE) -target_link_libraries( - sgc - INTERFACE -) +target_link_libraries(sgc INTERFACE) # ---- Install ---- include(CMakePackageConfigHelpers) include(GNUInstallDirs) -set(sgc_directory "sgc-${PROJECT_VERSION}") -set(sgc_include_directory "${CMAKE_INSTALL_INCLUDEDIR}") +set(SGC_DIRECTORY "sgc-${PROJECT_VERSION}") +set(SGC_INCLUDE_DIRECTORY "${CMAKE_INSTALL_INCLUDEDIR}") install( DIRECTORY "${PROJECT_SOURCE_DIR}/include/" - DESTINATION "${sgc_include_directory}" + DESTINATION "${SGC_INCLUDE_DIRECTORY}" COMPONENT sgc_Development ) install( TARGETS sgc EXPORT sgcTargets - INCLUDES DESTINATION "${sgc_include_directory}" + INCLUDES DESTINATION "${SGC_INCLUDE_DIRECTORY}" ) write_basic_package_version_file( @@ -61,11 +57,11 @@ write_basic_package_version_file( ARCH_INDEPENDENT ) -set(sgc_install_cmakedir "${CMAKE_INSTALL_LIBDIR}/cmake/${sgc_directory}") +set(SGC_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${SGC_DIRECTORY}") install( FILES "${PROJECT_BINARY_DIR}/sgc-config-version.cmake" - DESTINATION "${sgc_install_cmakedir}" + DESTINATION "${SGC_INSTALL_CMAKEDIR}" COMPONENT sgc_Development ) @@ -73,10 +69,10 @@ install( EXPORT sgcTargets FILE sgc-config.cmake NAMESPACE sgc:: - DESTINATION "${sgc_install_cmakedir}" + DESTINATION "${SGC_INSTALL_CMAKEDIR}" COMPONENT sgc_Development ) if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) - include(CPack) + include(CPack) endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index fddab47..4197ad2 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -5,46 +5,59 @@ enable_testing() # ---- Dependencies ---- -set( - sgc_INCLUDE_WITHOUT_SYSTEM - YES - CACHE - INTERNAL - "Turn the warning guard off to have errors appear in test builds" -) - include(FetchContent) -FetchContent_Declare(sgc SOURCE_DIR "${PROJECT_SOURCE_DIR}/..") -FetchContent_MakeAvailable(sgc) +fetchcontent_declare(sgc SOURCE_DIR "${PROJECT_SOURCE_DIR}/..") +fetchcontent_makeavailable(sgc) if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang") - target_compile_options(sgc INTERFACE -Wall -Wextra) + target_compile_options(sgc INTERFACE -Wall -Wextra) endif() # ---- Dependencies ---- include(FetchContent) -FetchContent_Declare( - unity - GIT_REPOSITORY https://github.com/ThrowTheSwitch/Unity - GIT_TAG origin/master - GIT_SHALLOW TRUE) +fetchcontent_declare( + UNITY + GIT_REPOSITORY https://github.com/red0124/Unity + GIT_TAG origin/master + GIT_SHALLOW TRUE +) -FetchContent_MakeAvailable(unity) -set(unity "${FETCHCONTENT_BASE_DIR}/unity-src") +fetchcontent_makeavailable(UNITY) +set(UNITY "${FETCHCONTENT_BASE_DIR}/unity-src") # ---- Test ---- enable_testing() -foreach(name IN ITEMS test_algorithm test_deque test_forward_list test_list - test_map test_priority_queue test_queue test_set test_stack - test_fs_deque test_fs_priority_queue test_fs_queue - test_fs_stack test_fs_unordered_map test_fs_unordered_set - test_fs_vector test_string test_unordered_map test_unordered_set - test_vector test_utils) - add_executable("${name}" "${name}.c") - target_link_libraries("${name}" PRIVATE sgc::sgc unity) - target_compile_definitions("${name}" PRIVATE CMAKE_GITHUB_CI) - add_test("${name}" "${name}" "./${name}") +foreach( + name + IN + ITEMS + test_algorithm + test_deque + test_forward_list + test_list + test_map + test_priority_queue + test_queue + test_set + test_stack + test_fs_deque + test_fs_priority_queue + test_fs_queue + test_fs_stack + test_fs_unordered_map + test_fs_unordered_set + test_fs_vector + test_string + test_unordered_map + test_unordered_set + test_vector + test_utils +) + add_executable("${name}" "${name}.c") + target_link_libraries("${name}" PRIVATE sgc::sgc unity) + target_compile_definitions("${name}" PRIVATE CMAKE_GITHUB_CI) + add_test("${name}" "${name}" "./${name}") endforeach()