mirror of
https://github.com/ttroy50/cmake-examples.git
synced 2025-12-18 12:14:36 +03:00
Update to minimum CMake 3.5
And modernise some examples.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
# Set the project name
|
||||
project (boost_unit_test)
|
||||
@@ -7,19 +7,21 @@ project (boost_unit_test)
|
||||
# find a boost install with the libraries unit_test_framework
|
||||
find_package(Boost 1.46.1 REQUIRED COMPONENTS unit_test_framework)
|
||||
|
||||
set (SOURCES
|
||||
# Add an library for the example classes
|
||||
add_library(example_boost_unit_test
|
||||
Reverse.cpp
|
||||
Palindrome.cpp
|
||||
)
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
# Add an library for the example classes
|
||||
add_library(example_boost_unit_test ${SOURCES})
|
||||
target_include_directories(example_boost_unit_test
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
target_link_libraries(example_boost_unit_test
|
||||
PUBLIC
|
||||
Boost::boost
|
||||
)
|
||||
|
||||
#############################################
|
||||
# Unit tests
|
||||
@@ -32,7 +34,7 @@ add_executable(unit_tests unit_tests.cpp)
|
||||
|
||||
target_link_libraries(unit_tests
|
||||
example_boost_unit_test
|
||||
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}
|
||||
Boost::unit_test_framework
|
||||
)
|
||||
|
||||
target_compile_definitions(unit_tests
|
||||
|
||||
@@ -59,10 +59,13 @@ add_executable(unit_tests unit_tests.cpp)
|
||||
|
||||
target_link_libraries(unit_tests
|
||||
example_boost_unit_test
|
||||
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}
|
||||
Boost::unit_test_framework
|
||||
)
|
||||
|
||||
add_definitions (-DBOOST_TEST_DYN_LINK)
|
||||
target_compile_definitions(unit_tests
|
||||
PRIVATE
|
||||
BOOST_TEST_DYN_LINK
|
||||
)
|
||||
----
|
||||
|
||||
In the above code, a unit test binary is added, which links against the boost unit-test-framework
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
# Set the project name
|
||||
project (catch_unit_test)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
# Set the project name
|
||||
project (google_test_example)
|
||||
|
||||
Reference in New Issue
Block a user