Modernize cmake.

topic/diffentiators
Vincent Samy 2019-10-10 13:10:20 +09:00
rodzic 26ca2a0fa6
commit 8cc9166c95
4 zmienionych plików z 33 dodań i 33 usunięć

Wyświetl plik

@ -26,30 +26,27 @@
# either expressed or implied, of the FreeBSD Project.
# Version minimum
cmake_minimum_required(VERSION 3.0.2)
include(cmake/base.cmake)
include(cmake/eigen.cmake)
include(cmake/msvc-specific.cmake)
cmake_minimum_required(VERSION 3.1.3)
set(PROJECT_NAME diFi++)
set(PROJECT_DESCRIPTION "Filter using rational transfer function")
set(PROJECT_URL "...")
set(PROJECT_URL "https://github.com/vsamy/DiFipp")
SET(PROJECT_DEBUG_POSTFIX "_d")
#SET(CXX_DISABLE_WERROR True)
set(DOXYGEN_USE_MATHJAX "NO")
project(${PROJECT_NAME} CXX)
set(CMAKE_CXX_STANDARD 14)
setup_project()
option(DISABLE_TESTS "Disable unit tests." OFF)
option(BUILD_TESTING "Disable unit tests." ON)
option(BUILD_TEST_STATIC_BOOST "Build unit tests with static boost libraries" OFF)
option(THROW_ON_CONTRACT_VIOLATION "Throw an error when program fails." ON)
option(TERMINATE_ON_CONTRACT_VIOLATION "Terminate program when an error occurs. (Default)" OFF)
option(UNENFORCED_ON_CONTRACT_VIOLATION "Do not perform any check." OFF)
include(cmake/base.cmake)
include(cmake/msvc-specific.cmake)
project(${PROJECT_NAME} CXX)
# Handle contracts specifications
if(${THROW_ON_CONTRACT_VIOLATION})
add_compile_options(-DGSL_THROW_ON_CONTRACT_VIOLATION)
@ -61,19 +58,18 @@ endif()
# for MSVC
if(MSVC)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /W1 /MP")
set(CMAKE_MSVCIDE_RUN_PATH "\$(SolutionDir)/src/\$(Configuration)")
endif()
# Eigen
set(Eigen_REQUIRED "eigen3 >= 3.3")
search_for_eigen()
add_project_dependency(Eigen3 REQUIRED)
add_subdirectory(include)
if(NOT ${DISABLE_TESTS})
if(${BUILD_TESTING})
add_subdirectory(tests)
endif()
pkg_config_append_libs(${PROJECT_NAME})
setup_project_finalize()
setup_project_finalize()
setup_project_package_finalize()

2
cmake

@ -1 +1 @@
Subproject commit 6ccc9f9b2a2ff510ae7754c515c72f8e38410447
Subproject commit 192812cc2c5d8aaffbc8536d0b0a2a7c11dad53b

Wyświetl plik

@ -42,8 +42,10 @@ set(HEADERS
set(GSL_HEADERS gsl/gsl_assert.h)
add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(${PROJECT_NAME} INTERFACE ${HEADERS} ${GSL_HEADERS})
target_include_directories(${PROJECT_NAME} INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<INSTALL_INTERFACE:include>)
target_include_directories(${PROJECT_NAME} SYSTEM INTERFACE "${EIGEN3_INCLUDE_DIR}")
install(TARGETS ${PROJECT_NAME}
EXPORT "${TARGETS_EXPORT_NAME}"
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)

Wyświetl plik

@ -25,26 +25,28 @@
# of the authors and should not be interpreted as representing official policies,
# either expressed or implied, of the FreeBSD Project.
include(${CMAKE_SOURCE_DIR}/cmake/boost.cmake)
enable_testing()
set(BOOST_COMPONENTS unit_test_framework)
search_for_boost()
add_definitions(-DBOOST_TEST_DYN_LINK)
include_directories(${Boost_INCLUDE_DIRS})
include_directories(${CMAKE_SOURCE_DIR}/include)
link_directories(${Boost_LIBRARY_DIR} ${Boost_LIBRARY_DIRS})
if(${BUILD_TEST_STATIC_BOOST})
set(Boost_USE_STATIC_LIBS ON)
set(BUILD_SHARED_LIBS OFF)
set(BOOST_DEFS "")
set(BUILD_TYPE STATIC)
else()
set(Boost_USE_STATIC_LIBS OFF)
set(BUILD_SHARED_LIBS ON)
set(BOOST_DEFS Boost::dynamic_linking)
set(BUILD_TYPE SHARED)
endif()
find_package(Boost REQUIRED COMPONENTS unit_test_framework)
macro(addTest testName)
add_executable(${testName} ${testName}.cpp)
if(NOT MSVC)
target_link_libraries(${testName} PUBLIC ${Boost_LIBRARIES})
endif()
add_test(${testName}Unit ${testName})
target_link_libraries(${testName} PRIVATE ${PROJECT_NAME} Boost::unit_test_framework)
# Adding a project configuration file (for MSVC only)
GENERATE_MSVC_DOT_USER_FILE(${testName})
generate_msvc_dot_user_file(${testName})
add_test(${testName}Unit ${testName})
endmacro(addTest)
addTest(GenericFilterTests)