list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
option (NLOPT_CXX "enable cxx routines" ON)
+option (NLOPT_FORTRAN "enable fortran tests" OFF)
option (BUILD_SHARED_LIBS "Build NLopt as a shared library" ON)
option (NLOPT_PYTHON "build python bindings" ON)
option (NLOPT_OCTAVE "build octave bindings" ON)
option (NLOPT_MATLAB "build matlab bindings" ON)
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_TESTS "build unit tests" ON)
option (NLOPT_TESTS "build unit tests" OFF)
endif ()
+if (NLOPT_FORTRAN)
+ enable_language (Fortran)
+endif ()
+
include (GNUInstallDirs)
# Offer the user the choice of overriding the installation directories
endif ()
option (WITH_THREADLOCAL "check thread local keyword" ON)
-if (WITH_THREADLOCAL AND NOT DEFINED HAVE_THREAD_LOCAL_STORAGE)
+if (WITH_THREADLOCAL AND NOT DEFINED THREADLOCAL)
foreach (_THREADLOCAL_KEY "__thread" "__declspec(thread)")
unset (HAVE_THREAD_LOCAL_STORAGE CACHE)
check_c_source_compiles("
int main(void) {
return 0;
}" HAVE_THREAD_LOCAL_STORAGE)
- if (${HAVE_THREAD_LOCAL_STORAGE})
- set (THREADLOCAL ${_THREADLOCAL_KEY})
+ if (HAVE_THREAD_LOCAL_STORAGE)
+ set (THREADLOCAL ${_THREADLOCAL_KEY} CACHE STRING "Thread local keyword")
endif ()
endforeach()
endif ()
+
if (NLOPT_CXX OR NLOPT_PYTHON OR NLOPT_GUILE OR NLOPT_OCTAVE)
check_cxx_symbol_exists (__cplusplus ciso646 SYSTEM_HAS_CXX)
if (SYSTEM_HAS_CXX)
target_include_directories (${nlopt_lib} INTERFACE "$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/src/api>" "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
if (BUILD_SHARED_LIBS)
- target_compile_definitions (${nlopt_lib} PUBLIC -DNLOPT_DLL)
- target_compile_definitions (${nlopt_lib} PRIVATE -DNLOPT_DLL_EXPORT)
+ target_compile_definitions (${nlopt_lib} PUBLIC NLOPT_DLL)
+ target_compile_definitions (${nlopt_lib} PRIVATE NLOPT_DLL_EXPORT)
endif ()
# pass -fPIC in case swig module is built with static library