@@ -37,10 +37,35 @@ set(__ignore__ ${CMAKE_C_COMPILER})
3737# Options
3838#
3939#-------------------------------------------------
40- option (BOOST_OPENMETHOD_BUILD_TESTS "Build boost::openmethod tests even if BUILD_TESTING is OFF" OFF )
41- option (BOOST_OPENMETHOD_BUILD_EXAMPLES "Build boost::openmethod examples" ${BOOST_OPENMETHOD_IS_ROOT} )
42- option (BOOST_OPENMETHOD_MRDOCS_BUILD "Build the target for MrDocs: see mrdocs.yml" OFF )
43- option (BOOST_OPENMETHOD_WARNINGS_AS_ERRORS "Treat warnings as errors" OFF )
40+
41+ option (
42+ BOOST_OPENMETHOD_BUILD_TESTS
43+ "Build boost::openmethod tests even if BUILD_TESTING is OFF"
44+ ${BOOST_OPENMETHOD_IS_ROOT} )
45+
46+ if (BUILD_TESTING)
47+ set (BOOST_OPENMETHOD_BUILD_TESTS ON )
48+ endif ()
49+
50+ option (
51+ BOOST_OPENMETHOD_BUILD_EXAMPLES
52+ "Build boost::openmethod examples"
53+ ${BOOST_OPENMETHOD_IS_ROOT} )
54+ option (
55+ BOOST_OPENMETHOD_MRDOCS_BUILD
56+ "Build the target for MrDocs: see mrdocs.yml"
57+ OFF )
58+ option (
59+ BOOST_OPENMETHOD_WARNINGS_AS_ERRORS
60+ "Treat warnings as errors"
61+ OFF )
62+
63+ if (BOOST_OPENMETHOD_BUILD_EXAMPLES AND NOT BOOST_OPENMETHOD_BUILD_TESTS)
64+ message (
65+ WARNING
66+ "BOOST_OPENMETHOD_BUILD_EXAMPLES requires BOOST_OPENMETHOD_BUILD_TESTS. Examples will not be built." )
67+ set (BOOST_OPENMETHOD_BUILD_EXAMPLES OFF )
68+ endif ()
4469
4570# Check if environment variable BOOST_SRC_DIR is set
4671if (NOT DEFINED BOOST_SRC_DIR AND DEFINED ENV{BOOST_SRC_DIR})
@@ -77,9 +102,9 @@ endforeach ()
77102if (NOT BOOST_OPENMETHOD_MRDOCS_BUILD)
78103 if (BUILD_TESTING OR BOOST_OPENMETHOD_BUILD_TESTS)
79104 set (BOOST_OPENMETHOD_UNIT_TEST_LIBRARIES test )
80- endif ( )
81- if (BOOST_OPENMETHOD_BUILD_EXAMPLES )
82- set (BOOST_OPENMETHOD_EXAMPLE_LIBRARIES dll )
105+ if (BOOST_OPENMETHOD_BUILD_EXAMPLES )
106+ set (BOOST_OPENMETHOD_EXAMPLE_LIBRARIES dll )
107+ endif ( )
83108 endif ()
84109endif ()
85110# Complete dependency list
@@ -175,20 +200,15 @@ endif()
175200# Tests
176201#
177202#-------------------------------------------------
178- if (BUILD_TESTING OR BOOST_OPENMETHOD_BUILD_TESTS)
203+ if (BOOST_OPENMETHOD_BUILD_TESTS)
179204 enable_testing ()
180205 add_subdirectory (test )
181206 if (BOOST_OPENMETHOD_IS_ROOT)
182207 add_custom_target (all_with_tests ALL DEPENDS tests)
183208 endif ()
184- endif ()
185209
186- #-------------------------------------------------
187- #
188- # Examples
189- #
190- #-------------------------------------------------
191- if (BOOST_OPENMETHOD_BUILD_EXAMPLES)
192- enable_testing ()
193- add_subdirectory (doc /modules/ROOT/examples)
210+ # Examples
211+ if (BOOST_OPENMETHOD_BUILD_EXAMPLES)
212+ add_subdirectory (doc /modules/ROOT/examples)
213+ endif ()
194214endif ()
0 commit comments