chiark / gitweb /
CMake: Set CPACK variables in cache
[nlopt.git] / CMakeLists.txt
index 2cf3289aa6ef8c35a3d298db810113928b835894..0e40a8b1e244656172bbaeb9d969cfe28ee5fc1c 100644 (file)
@@ -38,6 +38,7 @@ set(SO_PATCH 0)
 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)
@@ -51,6 +52,10 @@ else ()
   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
@@ -258,8 +263,8 @@ get_target_property (NLOPT_PRIVATE_INCLUDE_DIRS ${nlopt_lib} INCLUDE_DIRECTORIES
 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
@@ -335,10 +340,10 @@ 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})