Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile tests only in top-level projects. #197

Merged
merged 3 commits into from
Jul 27, 2018
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ option (NLOPT_GUILE "build guile bindings" ON)
option (NLOPT_SWIG "use SWIG to build bindings" ON)
option (NLOPT_LINK_PYTHON "link Python libs" ON)

if (CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
option (NLOPT_BUILD_TESTS "build unit tests" ON)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably just NLOPT_TESTS to be shorter

else ()
option (NLOPT_BUILD_TESTS "build unit tests" OFF)
endif ()

set (NLOPT_SUFFIX)
if (NLOPT_CXX)
set (NLOPT_SUFFIX _cxx)
Expand Down Expand Up @@ -318,8 +324,10 @@ if (OCTAVE_FOUND OR Matlab_FOUND)
add_subdirectory (src/octave)
endif ()

enable_testing ()
add_subdirectory (test)
if (NLOPT_BUILD_TESTS)
enable_testing ()
add_subdirectory (test)
endif ()

set (CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
set (CPACK_PACKAGE_VERSION_MAJOR "${NLOPT_MAJOR_VERSION}")
Expand Down