From: Julien Schueller Date: Wed, 20 Jul 2016 14:36:27 +0000 (+0200) Subject: Default build (#74) X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=3343118e9af664524c44cf9bc9bdd6982599728f;p=nlopt.git Default build (#74) * Enable Matlab by default * Cleanup CMakeLists.txt --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 3fa727c..848d29a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,7 @@ option (WITH_CXX "enable cxx routines" OFF) option (BUILD_SHARED_LIBS "Build NLOPT as a shared library" ON) option (BUILD_PYTHON "build python bindings" ON) option (BUILD_OCTAVE "build octave bindings" ON) -option (BUILD_MATLAB "build matlab bindings" OFF) +option (BUILD_MATLAB "build matlab bindings" ON) option (BUILD_GUILE "build guile bindings" ON) option (USE_SWIG "use SWIG to build bindings" ON) @@ -48,13 +48,13 @@ set (INSTALL_DATA_DIR share/nlopt CACHE PATH "Installation directory fo set (INSTALL_CMAKE_DIR ${INSTALL_LIB_DIR}/cmake/nlopt CACHE PATH "Installation directory for cmake config files") # Make relative paths absolute (needed later on) -foreach(p LIB BIN INCLUDE DATA CMAKE) - set(var INSTALL_${p}_DIR) - set(RELATIVE_INSTALL_${p}_DIR ${INSTALL_${p}_DIR}) - if(NOT IS_ABSOLUTE "${${var}}") - set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}") - endif() -endforeach() +foreach (p LIB BIN INCLUDE DATA CMAKE) + set (var INSTALL_${p}_DIR) + set (RELATIVE_INSTALL_${p}_DIR ${INSTALL_${p}_DIR}) + if (NOT IS_ABSOLUTE "${${var}}") + set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}") + endif () +endforeach () set (CMAKE_INSTALL_RPATH ${INSTALL_LIB_DIR}) @@ -158,21 +158,21 @@ set (${INCLUDE_DIRECTORIES} "") include_directories ( ${CMAKE_BINARY_DIR}/api ${CMAKE_BINARY_DIR} - stogo - util - direct - cdirect - praxis - luksan - crs - mlsl - mma - cobyla - newuoa - neldermead - auglag - bobyqa - isres + stogo + util + direct + cdirect + praxis + luksan + crs + mlsl + mma + cobyla + newuoa + neldermead + auglag + bobyqa + isres slsqp esch api) @@ -182,29 +182,29 @@ include_directories ( # nlopt LIBRARY TARGET (SHARED OR STATIC) #============================================================================== -SET ( NLOPT_HEADERS +set (NLOPT_HEADERS api/nlopt.h ${CMAKE_BINARY_DIR}/api/nlopt.hpp ${CMAKE_BINARY_DIR}/api/nlopt.f ) -SET ( NLOPT_SOURCES - direct/DIRect.c direct/direct_wrap.c direct/DIRserial.c direct/DIRsubrout.c direct/direct-internal.h direct/direct.h - cdirect/cdirect.c cdirect/hybrid.c cdirect/cdirect.h - praxis/praxis.c praxis/praxis.h - luksan/plis.c luksan/plip.c luksan/pnet.c luksan/mssubs.c luksan/pssubs.c luksan/luksan.h - crs/crs.c crs/crs.h - mlsl/mlsl.c mlsl/mlsl.h - mma/mma.c mma/mma.h mma/ccsa_quadratic.c - cobyla/cobyla.c cobyla/cobyla.h - newuoa/newuoa.c newuoa/newuoa.h - neldermead/nldrmd.c neldermead/neldermead.h neldermead/sbplx.c - auglag/auglag.c auglag/auglag.h - bobyqa/bobyqa.c bobyqa/bobyqa.h - isres/isres.c isres/isres.h - slsqp/slsqp.c slsqp/slsqp.h - esch/esch.c esch/esch.h - api/general.c api/options.c api/optimize.c api/deprecated.c api/nlopt-internal.h api/nlopt.h api/f77api.c api/f77funcs.h api/f77funcs_.h api/nlopt.hpp api/nlopt-in.hpp - util/mt19937ar.c util/sobolseq.c util/soboldata.h util/timer.c util/stop.c util/nlopt-util.h util/redblack.c util/redblack.h util/qsort_r.c util/rescale.c - ) +set (NLOPT_SOURCES + direct/DIRect.c direct/direct_wrap.c direct/DIRserial.c direct/DIRsubrout.c direct/direct-internal.h direct/direct.h + cdirect/cdirect.c cdirect/hybrid.c cdirect/cdirect.h + praxis/praxis.c praxis/praxis.h + luksan/plis.c luksan/plip.c luksan/pnet.c luksan/mssubs.c luksan/pssubs.c luksan/luksan.h + crs/crs.c crs/crs.h + mlsl/mlsl.c mlsl/mlsl.h + mma/mma.c mma/mma.h mma/ccsa_quadratic.c + cobyla/cobyla.c cobyla/cobyla.h + newuoa/newuoa.c newuoa/newuoa.h + neldermead/nldrmd.c neldermead/neldermead.h neldermead/sbplx.c + auglag/auglag.c auglag/auglag.h + bobyqa/bobyqa.c bobyqa/bobyqa.h + isres/isres.c isres/isres.h + slsqp/slsqp.c slsqp/slsqp.h + esch/esch.c esch/esch.h + api/general.c api/options.c api/optimize.c api/deprecated.c api/nlopt-internal.h api/nlopt.h api/f77api.c api/f77funcs.h api/f77funcs_.h api/nlopt.hpp api/nlopt-in.hpp + util/mt19937ar.c util/sobolseq.c util/soboldata.h util/timer.c util/stop.c util/nlopt-util.h util/redblack.c util/redblack.h util/qsort_r.c util/rescale.c +) if (WITH_CXX) list (APPEND NLOPT_SOURCES stogo/global.cc stogo/linalg.cc stogo/local.cc stogo/stogo.cc stogo/tools.cc stogo/global.h stogo/linalg.h stogo/local.h stogo/stogo_config.h stogo/stogo.h stogo/tools.h) @@ -274,7 +274,6 @@ if (BUILD_OCTAVE) endif () if (BUILD_MATLAB) - cmake_minimum_required (VERSION 3.3) # for the matlab_add_mex macro find_package (Matlab) endif () diff --git a/octave/CMakeLists.txt b/octave/CMakeLists.txt index 0c8e6f3..ed4a6c2 100644 --- a/octave/CMakeLists.txt +++ b/octave/CMakeLists.txt @@ -27,5 +27,7 @@ if (OCTAVE_FOUND) endif () if (Matlab_FOUND) + cmake_minimum_required (VERSION 3.3) # for the matlab_add_mex macro + matlab_add_mex (NAME nlopt_optimize-mex SRC nlopt_optimize-mex.c OUTPUT_NAME nlopt_optimize LINK_TO ${nlopt_lib}) endif () diff --git a/swig/CMakeLists.txt b/swig/CMakeLists.txt index fafb512..16384b5 100644 --- a/swig/CMakeLists.txt +++ b/swig/CMakeLists.txt @@ -33,8 +33,8 @@ if (NUMPY_FOUND AND PYTHONLIBS_FOUND AND (SWIG_FOUND OR (EXISTS ${CMAKE_CURRENT_ swig_link_libraries (nlopt ${PYTHON_LIBRARIES}) endif () - install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/nlopt.py DESTINATION ${PYTHON_MODULE_PATH} ) - install ( TARGETS ${SWIG_MODULE_nlopt_REAL_NAME} LIBRARY DESTINATION ${PYTHON_MODULE_PATH} ) + install (FILES ${CMAKE_CURRENT_BINARY_DIR}/nlopt.py DESTINATION ${PYTHON_MODULE_PATH}) + install (TARGETS ${SWIG_MODULE_nlopt_REAL_NAME} LIBRARY DESTINATION ${PYTHON_MODULE_PATH}) endif ()