Commits

Ruben Martinez-Cantin committed 9a5508a

Simplifying linking among interface. Now python module is build separately.

Comments (0)

Files changed (5)

+# -------------------------------------------------------------------------
+#    This file is part of BayesOpt, an efficient C++ library for 
+#    Bayesian optimization.
+#
+#    Copyright (C) 2011-2013 Ruben Martinez-Cantin <rmcantin@unizar.es>
+# 
+#    BayesOpt is free software: you can redistribute it and/or modify it 
+#    under the terms of the GNU General Public License as published by
+#    the Free Software Foundation, either version 3 of the License, or
+#    (at your option) any later version.
+#
+#    BayesOpt is distributed in the hope that it will be useful, but 
+#    WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with BayesOpt.  If not, see <http://www.gnu.org/licenses/>.
+# ------------------------------------------------------------------------
+
 PROJECT(BayesOpt CXX)
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 
 
 set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /opt/local/lib /opt/local/Library)
 set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} /opt/local/include
-/opt/local/Library)
+                                             /opt/local/Library)
 set(CMAKE_PROGRAM_PATH ${CMAKE_PROGRAM_PATH} /opt/local/bin/ /opt/local/Library)
 
 
 
 if(BAYESOPT_PYTHON_INTERFACE)
   INCLUDE(PythonMagic)
-  SET(PYTHON_LIB  ${PYTHON_LIBRARIES} )
   INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
   SET(BAYESOPT_BUILD_SHARED ON CACHE BOOL "Build shared libraries?" FORCE)
 ELSE()
 endif()
 
 FIND_LIBRARY(NLOPT nlopt)
-
 IF(NLOPT MATCHES NLOPT-NOTFOUND)
   SET(NLOPT_BUILD ON CACHE BOOL "Build included version of NLOPT?")
 ELSE(NLOPT MATCHES NLOPT-NOTFOUND)
 
 INCLUDE(UseDoxygen)
 
-
 IF(BAYESOPT_BUILD_SOBOL)
   ADD_DEFINITIONS(-DUSE_SOBOL)	
   SET(SOBOL_SRC
   ./wrappers/bayesoptwpr.cpp
   )
 
-IF(BAYESOPT_PYTHON_INTERFACE)
-  SET(PYTHON_SRC  ./python/bayesopt.cpp)
-ELSE(BAYESOPT_PYTHON_INTERFACE)
-  SET(PYTHON_SRC)
-ENDIF(BAYESOPT_PYTHON_INTERFACE)
-
 
 INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/include 
                      ${CMAKE_SOURCE_DIR}/wrappers
 
 LINK_DIRECTORIES( ${CMAKE_SOURCE_DIR}/lib )
 
+IF(NLOPT_BUILD)
+  ADD_SUBDIRECTORY(nlopt)
+  include_directories(${CMAKE_SOURCE_DIR}/nlopt/api)
+  SET(EXT_LIBS nlopt)
+ELSE(NLOPT_BUILD)
+  SET(EXT_LIBS ${NLOPT})
+ENDIF(NLOPT_BUILD)
+
 
 IF(BAYESOPT_BUILD_SHARED)
   ADD_LIBRARY(bayesopt SHARED ${BAYESOPT_SRCS}   
-    ${WRAPPPERS_SRC} ${UTILS_SRC} ${PYTHON_SRC} )
+    ${WRAPPPERS_SRC} ${UTILS_SRC} )
+
+  IF(BAYESOPT_PYTHON_INTERFACE)
+    ADD_LIBRARY(esopt MODULE ${BAYESOPT_SRCS}   
+      ${WRAPPPERS_SRC} ${UTILS_SRC} ./python/bayesopt.cpp)
+    TARGET_LINK_LIBRARIES(esopt
+      ${EXT_LIBS} ${PYTHON_LIBRARIES} )
+  ENDIF(BAYESOPT_PYTHON_INTERFACE)
+
   IF(WIN32)
     ADD_DEFINITIONS(-DBAYESOPT_DLL)	
     # In new versions of CMAKE they use a different system and the
     # symbol is not defined
     ADD_DEFINITIONS(-Dbayesopt_EXPORT )
   ELSE()
-    SET_TARGET_PROPERTIES(bayesopt PROPERTIES PREFIX "" SUFFIX ".so")
+    IF(BAYESOPT_PYTHON_INTERFACE)
+      # Kind of a hack but it works
+      SET_TARGET_PROPERTIES(esopt PROPERTIES PREFIX "bay" SUFFIX ".so")
+    ENDIF(BAYESOPT_PYTHON_INTERFACE)
   ENDIF()
 ELSE()
   ADD_LIBRARY(bayesopt STATIC ${BAYESOPT_SRCS}   
-    ${WRAPPPERS_SRC} ${UTILS_SRC} ${PYTHON_SRC} )
+    ${WRAPPPERS_SRC} ${UTILS_SRC} )
 ENDIF()
 
+IF(NLOPT_BUILD)
+  add_dependencies(bayesopt nlopt)
+  IF(BAYESOPT_PYTHON_INTERFACE)
+    add_dependencies(esopt nlopt)
+  ENDIF(BAYESOPT_PYTHON_INTERFACE)
+ENDIF(NLOPT_BUILD)
+
+
 IF((BAYESOPT_BUILD_SHARED OR BAYESOPT_MATLAB_COMPATIBLE) AND NOT WIN32)
   SET_TARGET_PROPERTIES(bayesopt PROPERTIES COMPILE_FLAGS "-fPIC")
 ENDIF()
   
-
-IF(NLOPT_BUILD)
-  ADD_SUBDIRECTORY(nlopt)
-  include_directories(${CMAKE_SOURCE_DIR}/nlopt/api)
-  add_dependencies(bayesopt nlopt)
-  SET(EXT_LIBS nlopt)
-ELSE(NLOPT_BUILD)
-  SET(EXT_LIBS ${NLOPT})
-ENDIF(NLOPT_BUILD)
-
-TARGET_LINK_LIBRARIES(bayesopt
-  ${EXT_LIBS} ${PYTHON_LIB} )
-
+TARGET_LINK_LIBRARIES(bayesopt ${EXT_LIBS})
 
 IF(BAYESOPT_BUILD_EXAMPLES)
   ADD_SUBDIRECTORY(examples)
   LIBRARY DESTINATION lib
   ARCHIVE DESTINATION lib
 )
+
+IF(BAYESOPT_PYTHON_INTERFACE)
+  INSTALL(
+    TARGETS esopt
+    LIBRARY DESTINATION lib
+    ARCHIVE DESTINATION lib
+  )
+ENDIF(BAYESOPT_PYTHON_INTERFACE)

doxygen/install.dox

 and 2.7. The interface relies on Numpy arrays. If we want to select
 the option to compile the Python interface we can just run:
 \verbatim
->> cmake -DBUILD_PYTHON=ON . 
+>> cmake -DBAYESOPT_PYTHON_INTERFACE=ON . 
 \endverbatim
 or 
 \verbatim

matlab/compile_matlab.m

             -I../include -I../wrappers
     end
 else
-    if exist('../lib/libbayesopt.a','file')
-        disp('Compiling static library');
-        mex -output bayesoptcont bayesoptmex.c ../lib/libbayesopt.a ...
-        ../lib/libnlopt.a -I../include -I../wrappers -I../nlopt/api 
+    mex -output bayesoptcont bayesoptmex.c -L../lib -lbayesopt ...
+        -lnlopt -I../include -I../wrappers -I../nlopt/api 
 
-        mex -output bayesoptdisc bayesoptdiscmex.c ../lib/libbayesopt.a ...
-            ../lib/libnlopt.a -I../include -I../wrappers -I../nlopt/api 
-    else
-        if exist('../lib/bayesopt.so','file')
-            disp('Compiling dynamic library');
-            mex -g -output bayesoptcont bayesoptmex.c ../lib/bayesopt.so ...
-                -I../include -I../wrappers
+    mex -output bayesoptdisc bayesoptdiscmex.c -L../lib -lbayesopt ...
+        -lnlopt -I../include -I../wrappers -I../nlopt/api 
 
-            mex -g -output bayesoptdisc bayesoptdiscmex.c ../lib/bayesopt.so ...
-                -I../include -I../wrappers
+    % if exist('../lib/libbayesopt.a','file')
+    %     disp('Compiling static library');
+    %     mex -output bayesoptcont bayesoptmex.c ../lib/libbayesopt.a ...
+    %     ../lib/libnlopt.a -I../include -I../wrappers -I../nlopt/api 
+
+    %     mex -output bayesoptdisc bayesoptdiscmex.c ../lib/libbayesopt.a ...
+    %         ../lib/libnlopt.a -I../include -I../wrappers -I../nlopt/api 
+    % else
+    %     if exist('../lib/bayesopt.so','file')
+    %         disp('Compiling dynamic library');
+    %         mex -g -output bayesoptcont bayesoptmex.c ../lib/bayesopt.so ...
+    %             -I../include -I../wrappers
+
+    %         mex -g -output bayesoptdisc bayesoptdiscmex.c ../lib/bayesopt.so ...
+    %             -I../include -I../wrappers
                 
-        else
-            disp('Error: File not found');
-        end
-    end
+    %     else
+    %         disp('Error: File not found');
+    %     end
+    % end
 end

matlab/compile_octave.m

 % You can also change ../lib for the correspoding install path
 % Octave
-if exist('../lib/libbayesopt.a','file')
-    disp('Compiling static library');
-     mkoctfile -L../lib -lbayesopt -lnlopt -I../include -I../wrappers ...
-        --mex "-Wl,-rpath=../lib" --output bayesoptcont.mex ...
-        bayesoptmex.c
+mkoctfile -L../lib -lbayesopt -lnlopt -I../include -I../wrappers ...
+    --mex --output bayesoptcont.mex bayesoptmex.c
 
-    mkoctfile -L../lib -lbayesopt -lnlopt -I../include -I../wrappers ...
-        --mex "-Wl,-rpath=../lib" --output bayesoptdisc.mex ...
-        bayesoptdiscmex.c
-else %TODO: Does not work in MacOS
-    disp('Compiling dynamic library');
-    mkoctfile -L../lib -l:bayesopt.so -lnlopt -I../include -I../wrappers ...
-        --mex "-Wl,-rpath=../lib" --output bayesoptcont.mex ...
-        bayesoptmex.c
+mkoctfile -L../lib -lbayesopt -lnlopt -I../include -I../wrappers ...
+    --mex --output bayesoptdisc.mex bayesoptdiscmex.c
 
-    mkoctfile -L../lib -l:bayesopt.so -lnlopt -I../include -I../wrappers ...
-        --mex "-Wl,-rpath=../lib" --output bayesoptdisc.mex ...
-        bayesoptdiscmex.c
-end
+%     if exist('../lib/libbayesopt.a','file')
+%     disp('Compiling static library');
+%      mkoctfile -L../lib -lbayesopt -lnlopt -I../include -I../wrappers ...
+%         --mex --output bayesoptcont.mex bayesoptmex.c
+
+%     mkoctfile -L../lib -lbayesopt -lnlopt -I../include -I../wrappers ...
+%         --mex --output bayesoptdisc.mex bayesoptdiscmex.c
+% else % TODO: Does not work in MacOS
+%     if (~ismac)
+%         disp('Compiling dynamic library');
+%         mkoctfile -L../lib -l:bayesopt.so -lnlopt -I../include -I../wrappers ...
+%             --mex --output bayesoptcont.mex bayesoptmex.c
+
+%         mkoctfile -L../lib -l:bayesopt.so -lnlopt -I../include -I../wrappers ...
+%             --mex --output bayesoptdisc.mex bayesoptdiscmex.c
+%     else
+%         disp('Dynamic library not supported in MacOS');
+%     end
+% end
     

matplotpp/matplotpp.h

 Author: Yuichi Katori (yuichi.katori@gmail.com)
 Project:MATPLOT++ (MATLAB-like plotting tool in C++).
 Version:0.3.13
+
+Modified: Ruben Martinez-Cantin (2013)
+    - Fixed std namespace issue
+    - Fixed bugs
 ****************************************************************************/
 
 #include <GL/glut.h>