Skip to content

Commit

Permalink
some cleanup of the cmake scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
aoterodelaroza committed Feb 12, 2024
1 parent 571f995 commit aa2c79d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions cmake/Modules/FindNLOPT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
8 changes: 4 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,26 +110,26 @@ target_sources(critic2 PRIVATE $<TARGET_OBJECTS:json-fortran>)
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}")
Expand Down

0 comments on commit aa2c79d

Please sign in to comment.