From 64caa0a5b05a848a06a6cf0ecbe9fe1b4e6f8ee5 Mon Sep 17 00:00:00 2001 From: Julien Schueller Date: Mon, 11 Nov 2024 17:23:13 +0100 Subject: [PATCH] CMake: Disable tests by default --- .github/workflows/build.yml | 8 ++++---- CMakeLists.txt | 7 +------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 819229e7..0d330077 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,10 +11,10 @@ jobs: pip install mkdocs python-markdown-math --user PATH=$PATH:~/.local/bin mkdocs build mkdir build && pushd build - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_FORTRAN=ON -DCMAKE_C_FLAGS='-std=c89 -pedantic -D_POSIX_C_SOURCE=200809L -Wall -Wextra -Wshadow' -DCMAKE_CXX_FLAGS='-Wall -Wextra -pedantic -Wshadow' -DSWIG_COMPILE_FLAGS="-Wno-unused-parameter -Wno-missing-field-initializers" .. + cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_FORTRAN=ON -DCMAKE_C_FLAGS='-std=c89 -pedantic -D_POSIX_C_SOURCE=200809L -Wall -Wextra -Wshadow' -DCMAKE_CXX_FLAGS='-Wall -Wextra -pedantic -Wshadow' -DSWIG_COMPILE_FLAGS="-Wno-shadow -Wno-unused-parameter -Wno-missing-field-initializers" -DNLOPT_TESTS=ON .. make install -j4 && ctest -j4 --output-on-failure rm -rf * ~/.local - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_PYTHON=OFF -DNLOPT_OCTAVE=OFF -DNLOPT_GUILE=OFF -DNLOPT_FORTRAN=ON -DCMAKE_TOOLCHAIN_FILE=$PWD/../cmake/toolchain-x86_64-w64-mingw32.cmake .. + cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_PYTHON=OFF -DNLOPT_OCTAVE=OFF -DNLOPT_GUILE=OFF -DNLOPT_FORTRAN=ON -DCMAKE_TOOLCHAIN_FILE=$PWD/../cmake/toolchain-x86_64-w64-mingw32.cmake -DNLOPT_TESTS=ON .. make install -j4 macos: @@ -25,7 +25,7 @@ jobs: run: | brew upgrade && brew install swig octave guile mkdir build && pushd build - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_FORTRAN=OFF .. + cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_FORTRAN=OFF -DNLOPT_TESTS=ON .. make install -j3 && ctest --output-on-failure windows: @@ -36,7 +36,7 @@ jobs: shell: cmd run: | pip install numpy - cmake -DCMAKE_INSTALL_PREFIX=%cd:\=/%/install . + cmake -DCMAKE_INSTALL_PREFIX=%cd:\=/%/install -DNLOPT_TESTS=ON . cmake --build . --config Release --target install xcopy %cd%\install\bin\nlopt.dll %cd%\src\swig xcopy %cd%\install\Lib\site-packages\_nlopt*.pyd %cd%\src\swig diff --git a/CMakeLists.txt b/CMakeLists.txt index 43baf9f4..9fcac2a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,12 +44,7 @@ option (NLOPT_MATLAB "build matlab bindings" OFF) option (NLOPT_GUILE "build guile bindings" ON) option (NLOPT_SWIG "use SWIG to build bindings" ON) option (NLOPT_LUKSAN "enable LGPL Luksan solvers" ON) - -if (CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) - option (NLOPT_TESTS "build unit tests" ON) -else () - option (NLOPT_TESTS "build unit tests" OFF) -endif () +option (NLOPT_TESTS "build unit tests" OFF) if (NLOPT_FORTRAN) enable_language (Fortran)