Merge topic 'find-boost-test-version'

19d92d5e6e FindBoost: provide the version in x.y.z format
186f69cf26 FindBoost: test version variables

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2638
This commit is contained in:
Brad King
2018-11-21 12:37:04 +00:00
committed by Kitware Robot
3 changed files with 21 additions and 1 deletions
+2
View File
@@ -35,6 +35,7 @@ case results are reported in variables::
Boost_MAJOR_VERSION - Boost major version number (X in X.y.z)
Boost_MINOR_VERSION - Boost minor version number (Y in x.Y.z)
Boost_SUBMINOR_VERSION - Boost subminor version number (Z in x.y.Z)
Boost_VERSION_STRING - Boost version number in x.y.z format
Boost_LIB_DIAGNOSTIC_DEFINITIONS (Windows)
- Pass to add_definitions() to have diagnostic
information about Boost's automatic linking
@@ -1371,6 +1372,7 @@ if(Boost_INCLUDE_DIR)
math(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000")
math(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000")
math(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100")
set(Boost_VERSION_STRING "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
string(APPEND Boost_ERROR_REASON
"Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}\nBoost include path: ${Boost_INCLUDE_DIR}")
+3
View File
@@ -13,6 +13,9 @@ if(NOT Boost_PROGRAM_OPTIONS_FOUND)
message(FATAL_ERROR "Optional Boost component \"program_options\" not found which is unexpected")
endif(NOT Boost_PROGRAM_OPTIONS_FOUND)
add_definitions(-DCMAKE_EXPECTED_BOOST_VERSION="${Boost_VERSION}")
add_definitions(-DCMAKE_EXPECTED_BOOST_VERSION_COMPONENTS="${Boost_VERSION_STRING}")
add_executable(test_boost_tgt main.cxx)
target_link_libraries(test_boost_tgt
Boost::dynamic_linking
+16 -1
View File
@@ -20,5 +20,20 @@ int main()
boost::thread foo(threadmain);
foo.join();
return 0;
int version = BOOST_VERSION;
int major = version / 100000;
int minor = version / 100 % 1000;
int patch = version % 100;
char version_string[100];
snprintf(version_string, sizeof(version_string), "%d.%d.%d", major, minor,
patch);
printf("Found Boost version %s, expected version %s\n", version_string,
CMAKE_EXPECTED_BOOST_VERSION_COMPONENTS);
int ret = strcmp(version_string, CMAKE_EXPECTED_BOOST_VERSION_COMPONENTS);
char raw_version_string[100];
snprintf(raw_version_string, sizeof(raw_version_string), "%d",
BOOST_VERSION);
printf("Found Boost version %s, expected version %s\n", raw_version_string,
CMAKE_EXPECTED_BOOST_VERSION);
return ret | strcmp(raw_version_string, CMAKE_EXPECTED_BOOST_VERSION);
}