From aa2c79d4825b343f281783852424887070b27220 Mon Sep 17 00:00:00 2001 From: Alberto Otero de la Roza Date: Mon, 12 Feb 2024 10:57:42 +0100 Subject: [PATCH] some cleanup of the cmake scripts --- CMakeLists.txt | 5 ++++- cmake/Modules/FindNLOPT.cmake | 3 +++ src/CMakeLists.txt | 8 ++++---- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eb01cbd1..9575aeec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,6 +93,7 @@ option(USE_EXTERNAL_LAPACK "Use external LAPACK/BLAS library (linear algebra ope option(USE_LIBXC "Use the libxc library for access (exchange-correlation energies and potentials)." ON) option(USE_LIBCINT "Use the libcint library (calculation of molecular integrals with Gaussian functions)." ON) option(USE_READLINE "Use the readline library (improved command-line interface)." ON) +option(USE_NLOPT "Use the nlopt library (global optimization for variable-cell crystal structure comparison)." ON) option(ENABLE_OPENMP "Enable OpenMP parallelization." ON) option(BUILD_STATIC "Build critic2 statically (tested only on linux, and no GUI)." OFF) @@ -253,7 +254,9 @@ if (USE_LIBCINT) endif() ## nlopt -find_package(NLOPT) +if (USE_NLOPT) + find_package(NLOPT) +endif() ## the syntax.txt target add_custom_target(syntax diff --git a/cmake/Modules/FindNLOPT.cmake b/cmake/Modules/FindNLOPT.cmake index a76642ba..f71e2796 100644 --- a/cmake/Modules/FindNLOPT.cmake +++ b/cmake/Modules/FindNLOPT.cmake @@ -46,3 +46,6 @@ find_package_handle_standard_args(NLOPT FAIL_MESSAGE DEFAULT_MSG REQUIRED_VARS NLOPT_INCLUDE_DIRS NLOPT_LIBRARIES VERSION_VAR NLOPT_VERSION) + +# hide library and include variables +mark_as_advanced(NLOPT_INCLUDE_DIRS NLOPT_LIBRARIES) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7db2a8be..fa9735d0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -110,26 +110,26 @@ target_sources(critic2 PRIVATE $) add_dependencies(critic2_core json-fortran) ## libxc -if (LIBXC_FOUND) +if (USE_LIBXC AND LIBXC_FOUND) include_directories("${LIBXC_INCLUDE_DIRS}") target_link_libraries(critic2 PRIVATE ${LIBXC_xcf90_LIBRARY} ${LIBXC_xc_LIBRARY}) add_definitions("-DHAVE_LIBXC") endif() ## libcint -if (LIBCINT_FOUND) +if (USE_LIBCINT AND LIBCINT_FOUND) target_link_libraries(critic2 PRIVATE ${LIBCINT_LIBRARY}) add_definitions("-DHAVE_CINT") endif() ## readline -if (READLINE_FOUND) +if (USE_READLINE AND READLINE_FOUND) target_link_libraries(critic2 PRIVATE ${READLINE_LIBRARY}) add_definitions("-DHAVE_READLINE") endif() ## libnlopt -if (NLOPT_FOUND) +if (USE_NLOPT AND NLOPT_FOUND) target_link_libraries(critic2 PRIVATE ${NLOPT_LIBRARIES}) add_definitions("-DHAVE_NLOPT") include_directories("${NLOPT_INCLUDE_DIRS}")