cmake_minimum_required (VERSION 2.8.5)\r
\r
if (NOT DEFINED CMAKE_BUILD_TYPE)\r
- set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type")\r
+ set (CMAKE_BUILD_TYPE Release CACHE STRING "Build type")\r
endif ()\r
\r
-project (nlopt C)\r
+project (nlopt)\r
\r
list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)\r
\r
option (WITH_CXX "enable cxx routines" OFF)\r
-option (BUILD_SHARED_LIBS "Build NLOPT as a shared library" ON)\r
+option (BUILD_SHARED_LIBS "Build NLopt as a shared library" ON)\r
option (BUILD_PYTHON "build python bindings" ON)\r
option (BUILD_OCTAVE "build octave bindings" ON)\r
option (BUILD_MATLAB "build matlab bindings" ON)\r
set (NLOPT_SUFFIX _cxx)\r
endif ()\r
\r
-if (WITH_CXX OR BUILD_PYTHON OR BUILD_GUILE OR BUILD_OCTAVE)\r
- enable_language (CXX)\r
-endif ()\r
-\r
include (GNUInstallDirs)\r
\r
# Offer the user the choice of overriding the installation directories\r
include (CheckCCompilerFlag)\r
include (CheckCXXSymbolExists)\r
include (CheckCXXCompilerFlag)\r
+include (CheckLibraryExists)\r
\r
#==============================================================================\r
# COMPILATION CHECKINGS and CONFIGURATION GENERATION\r
check_type_size ("unsigned int" SIZEOF_UNSIGNED_INT)\r
check_type_size ("unsigned long" SIZEOF_UNSIGNED_LONG)\r
\r
+check_library_exists ("m" sqrt "" HAVE_LIBM)\r
+if (HAVE_LIBM)\r
+ set (M_LIBRARY m)\r
+endif()\r
+\r
if (NOT DEFINED HAVE_FPCLASSIFY)\r
message(STATUS "Looking for fpclassify")\r
- file (WRITE ${CMAKE_BINARY_DIR}/fpclassify.c "#include <math.h>\n")\r
- file (APPEND ${CMAKE_BINARY_DIR}/fpclassify.c "int main(void) {\n")\r
- file (APPEND ${CMAKE_BINARY_DIR}/fpclassify.c "if (!fpclassify(3.14159)) fpclassify(2.7183);\n")\r
- file (APPEND ${CMAKE_BINARY_DIR}/fpclassify.c " return 0; }\n")\r
+ file (WRITE ${PROJECT_BINARY_DIR}/fpclassify.c "#include <math.h>\n")\r
+ file (APPEND ${PROJECT_BINARY_DIR}/fpclassify.c "int main(void) {\n")\r
+ file (APPEND ${PROJECT_BINARY_DIR}/fpclassify.c "if (!fpclassify(3.14159)) fpclassify(2.7183);\n")\r
+ file (APPEND ${PROJECT_BINARY_DIR}/fpclassify.c " return 0; }\n")\r
try_compile (HAVE_FPCLASSIFY\r
- ${CMAKE_BINARY_DIR}/build_fpclassify\r
- ${CMAKE_BINARY_DIR}/fpclassify.c\r
+ ${PROJECT_BINARY_DIR}/build_fpclassify\r
+ ${PROJECT_BINARY_DIR}/fpclassify.c\r
CMAKE_FLAGS -DLINK_LIBRARIES=m)\r
message(STATUS "Looking for fpclassify - ${HAVE_FPCLASSIFY}")\r
endif ()\r
#==============================================================================\r
set (${INCLUDE_DIRECTORIES} "")\r
include_directories (\r
- ${CMAKE_BINARY_DIR}/api\r
- ${CMAKE_BINARY_DIR}\r
+ ${PROJECT_BINARY_DIR}/api\r
+ ${PROJECT_BINARY_DIR}\r
stogo\r
util\r
direct\r
#==============================================================================\r
\r
set (NLOPT_HEADERS \r
- api/nlopt.h ${CMAKE_BINARY_DIR}/api/nlopt.hpp ${CMAKE_BINARY_DIR}/api/nlopt.f\r
+ api/nlopt.h ${PROJECT_BINARY_DIR}/api/nlopt.hpp ${PROJECT_BINARY_DIR}/api/nlopt.f\r
)\r
\r
set (NLOPT_SOURCES \r
\r
set (nlopt_lib nlopt${NLOPT_SUFFIX})\r
add_library (${nlopt_lib} ${NLOPT_SOURCES})\r
+target_link_libraries (${nlopt_lib} ${M_LIBRARY})\r
+\r
set_target_properties (${nlopt_lib} PROPERTIES SOVERSION 0)\r
set_target_properties (${nlopt_lib} PROPERTIES VERSION 0.9.0)\r
\r