X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=CMakeLists.txt;h=0e40a8b1e244656172bbaeb9d969cfe28ee5fc1c;hb=37b74a8c2037eea5dc72fea7eeb9b850fa978913;hp=6f91eb000b46bd76108367f0f7a056e0f3a5dce2;hpb=eab47e7252fe5d3736d3468fb69af06edfce57e3;p=nlopt.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f91eb0..0e40a8b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,20 +20,40 @@ endif () project (nlopt) +#============================================================================== +# version +set (NLOPT_MAJOR_VERSION "2") +set (NLOPT_MINOR_VERSION "5") +set (NLOPT_BUGFIX_VERSION "0") +set (NLOPT_VERSION_STRING ${NLOPT_MAJOR_VERSION}.${NLOPT_MINOR_VERSION}.${NLOPT_BUGFIX_VERSION}) +message (STATUS "NLopt version ${NLOPT_VERSION_STRING}") + +# This is the ABI version number, which differes from the API version above +# (it indicates ABI compatibility), but they are typically incremented together. +set(SO_MAJOR 0) +set(SO_MINOR 9) +set(SO_PATCH 0) +#============================================================================== + list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) -option (NLOPT_CXX "enable cxx routines" OFF) +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) -set (NLOPT_SUFFIX) -if (NLOPT_CXX) - set (NLOPT_SUFFIX _cxx) +if (CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) + option (NLOPT_TESTS "build unit tests" ON) +else () + option (NLOPT_TESTS "build unit tests" OFF) +endif () + +if (NLOPT_FORTRAN) + enable_language (Fortran) endif () include (GNUInstallDirs) @@ -122,7 +142,7 @@ if (NOT DEFINED HAVE_FPCLASSIFY) 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(" @@ -131,12 +151,13 @@ if (WITH_THREADLOCAL AND NOT DEFINED HAVE_THREAD_LOCAL_STORAGE) 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) @@ -152,15 +173,6 @@ if (NLOPT_CXX OR NLOPT_PYTHON OR NLOPT_GUILE OR NLOPT_OCTAVE) endif () endif () -#============================================================================== -# version -#============================================================================== -set (NLOPT_MAJOR_VERSION "2") -set (NLOPT_MINOR_VERSION "5") -set (NLOPT_BUGFIX_VERSION "0") -set (NLOPT_VERSION_STRING ${NLOPT_MAJOR_VERSION}.${NLOPT_MINOR_VERSION}.${NLOPT_BUGFIX_VERSION}) -message (STATUS "NLopt version ${NLOPT_VERSION_STRING}") - #============================================================================== # CREATE nlopt_config.h #============================================================================== @@ -214,12 +226,12 @@ endif () install (FILES ${NLOPT_HEADERS} DESTINATION ${RELATIVE_INSTALL_INCLUDE_DIR}) -set (nlopt_lib nlopt${NLOPT_SUFFIX}) +set (nlopt_lib nlopt) add_library (${nlopt_lib} ${NLOPT_SOURCES}) target_link_libraries (${nlopt_lib} ${M_LIBRARY}) -set_target_properties (${nlopt_lib} PROPERTIES SOVERSION 0) -set_target_properties (${nlopt_lib} PROPERTIES VERSION 0.9.0) +set_target_properties (${nlopt_lib} PROPERTIES SOVERSION ${SO_MAJOR}) +set_target_properties (${nlopt_lib} PROPERTIES VERSION "${SO_MAJOR}.${SO_MINOR}.${SO_PATCH}") #============================================================================== # INCLUDE DIRECTORIES @@ -251,8 +263,8 @@ get_target_property (NLOPT_PRIVATE_INCLUDE_DIRS ${nlopt_lib} INCLUDE_DIRECTORIES target_include_directories (${nlopt_lib} INTERFACE "$" "$/${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 @@ -318,18 +330,20 @@ if (OCTAVE_FOUND OR Matlab_FOUND) add_subdirectory (src/octave) endif () -enable_testing () -add_subdirectory (test) +if (NLOPT_TESTS) + enable_testing () + add_subdirectory (test) +endif () set (CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}") set (CPACK_PACKAGE_VERSION_MAJOR "${NLOPT_MAJOR_VERSION}") set (CPACK_PACKAGE_VERSION_MINOR "${NLOPT_MINOR_VERSION}") set (CPACK_PACKAGE_VERSION_PATCH "${NLOPT_BUGFIX_VERSION}") set (CPACK_SOURCE_GENERATOR "TBZ2;TGZ" ) -set (CPACK_BINARY_STGZ "OFF" ) -set (CPACK_BINARY_TBZ2 "ON" ) -set (CPACK_BINARY_TGZ "ON" ) -set (CPACK_BINARY_TZ "OFF" ) +set (CPACK_BINARY_STGZ OFF CACHE BOOL "STGZ") +set (CPACK_BINARY_TBZ2 ON CACHE BOOL "TBZ2") +set (CPACK_BINARY_TGZ ON CACHE BOOL "TGZ") +set (CPACK_BINARY_TZ OFF CACHE BOOL "TZ") set (CPACK_SOURCE_IGNORE_FILES ".git;/build;.*~;${CPACK_SOURCE_IGNORE_FILES}") set (CPACK_SOURCE_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${NLOPT_VERSION_STRING})