瀏覽代碼

updated python build system

Former-commit-id: bf79f74c4ae405ea740618e630e64d3848310007
Daniele Panozzo 9 年之前
父節點
當前提交
93a6a05509

+ 2 - 2
cmake/CMakeLists.txt

@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.6)
 project(libigl)
 
 ### Available options ###
-option(LIBIGL_USE_STATIC_LIBRARY "Use libIGL as static library" ON)
+option(LIBIGL_USE_STATIC_LIBRARY "Use libIGL as static library" OFF)
 option(LIBIGL_WITH_BBW         "Use BBW"            OFF)
 option(LIBIGL_WITH_BOOLEAN     "Use Cork boolean"   OFF)
 option(LIBIGL_WITH_CGAL        "Use CGAL"           OFF)
@@ -172,7 +172,7 @@ IF(LIBIGL_WITH_COMISO)
 
   if(LIBIGL_USE_STATIC_LIBRARY)
     include_directories(${COMISO_INCLUDE_DIRS})
-    CompileIGL_Module("comiso")
+    CompileIGL_Module_Copyleft("comiso")
   endif()
 endif()
 

+ 41 - 100
python/CMakeLists.txt

@@ -1,5 +1,4 @@
 cmake_minimum_required(VERSION 2.8)
-
 project(pybind)
 
 IF(MSVC)
@@ -10,8 +9,6 @@ IF(MSVC)
   SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/../ )
 ENDIF(MSVC)
 
-SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../tutorial/cmake)
-
 if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
   message(STATUS "Setting build type to 'MinSizeRel' as none was specified.")
   set(CMAKE_BUILD_TYPE MinSizeRel CACHE STRING "Choose the type of build." FORCE)
@@ -19,12 +16,6 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
     "MinSizeRel" "RelWithDebInfo")
 endif()
 
-find_package(OpenGL QUIET)
-
-if (OPENGL_FOUND)
-  add_definitions(-DPY_VIEWER)
-endif (OPENGL_FOUND)
-
 # Force a specific python version
 # SET(PYTHON_LIBRARIES "D:/Python34/libs/python34.lib")
 # SET(PYTHON_INCLUDE_DIR "D:/Python34/include")
@@ -62,118 +53,68 @@ include_directories(${PYTHON_INCLUDE_DIR} include)
 ## include pybing
 include_directories(${PROJECT_SOURCE_DIR}/../external/pybind11/include)
 
-## include eigen
-include_directories(${PROJECT_SOURCE_DIR}/../external/nanogui/ext/eigen)
-
 ## include libigl
-include_directories(${PROJECT_SOURCE_DIR}/../include)
-
-if (OPENGL_FOUND)
-
-  ## include glew
-  if(NOT APPLE)
-    find_package(GLEW REQUIRED)
-    include_directories( ${GLEW_INCLUDE_DIR} )
-  	set(SHARED_SOURCES ${SHARED_SOURCES} ${GLEW_SOURCES})
-  endif(NOT APPLE)
-
-
-  # include nanogui and dependencies
+option(LIBIGL_USE_STATIC_LIBRARY "Use LibIGL as static library" OFF)
+option(LIBIGL_WITH_VIEWER      "Use Nanogui Viewer" ON)
+option(LIBIGL_WITH_BBW         "Use BBW"            ON)
+option(LIBIGL_WITH_EMBREE      "Use Embree"         ON)
+option(LIBIGL_WITH_OPENGL      "Use OpenGL"         ON)
+option(LIBIGL_WITH_PNG         "Use PNG"            ON)
+option(LIBIGL_WITH_TETGEN      "Use Tetgen"         ON)
+option(LIBIGL_WITH_TRIANGLE    "Use Triangle"       ON)
+option(LIBIGL_WITH_XML         "Use XML"            ON)
+option(LIBIGL_WITH_LIM         "Use LIM"            ON)
+option(LIBIGL_WITH_COMISO      "Use CoMiso"         ON)
+option(LIBIGL_WITH_BOOLEAN     "Use Cork boolean"   OFF)
+option(LIBIGL_WITH_MATLAB      "Use Matlab"         OFF)
+option(LIBIGL_WITH_MOSEK       "Use MOSEK"          OFF)
+
+option(LIBIGL_WITH_CGAL        "Use CGAL"           OFF)
+if(LIBIGL_WITH_CGAL) # Do not remove or move this block, cgal strange build system fails without it
+  find_package(CGAL REQUIRED)
+  set(CGAL_DONT_OVERRIDE_CMAKE_FLAGS TRUE CACHE BOOL "CGAL's CMAKE Setup is super annoying ")
+  include(${CGAL_USE_FILE})
+endif()
 
-  set(NANOGUI_BUILD_PYTHON OFF CACHE BOOL " " FORCE)
-  set(NANOGUI_BUILD_EXAMPLE OFF CACHE BOOL " " FORCE)
-  set(NANOGUI_BUILD_SHARED OFF CACHE BOOL " " FORCE)
-  add_definitions(-DIGL_VIEWER_WITH_NANOGUI)
-  
-  add_subdirectory("../external/nanogui/" "nanogui")
-  include_directories("../external/nanogui/include")
-  include_directories("../external/nanogui/ext/glfw/include")
-  include_directories("../external/nanogui/ext/nanovg/src")
+add_subdirectory("${PROJECT_SOURCE_DIR}/../cmake" "libigl")
 
-  if(UNIX AND NOT APPLE)
-	find_package(GLFW REQUIRED)
-  endif(UNIX AND NOT APPLE)
+### ligIGL information ###
+message("libIGL includes: ${LIBIGL_INCLUDE_DIRS}")
+message("libIGL libraries: ${LIBIGL_LIBRARIES}")
+message("libIGL extra sources: ${LIBIGL_EXTRA_SOURCES}")
+message("libIGL extra libraries: ${LIBIGL_EXTRA_LIBRARIES}")
+message("libIGL definitions: ${LIBIGL_DEFINITIONS}")
 
+### Prepare the build environment
 
-  list(APPEND SHARED_LIBRARIES "nanogui" ${OPENGL_LIBRARIES} ${GLFW_LIBRARIES})
+include_directories(${LIBIGL_INCLUDE_DIRS})
+add_definitions(${LIBIGL_DEFINITIONS})
 
+## Optional modules
+if (LIBIGL_WITH_OPENGL)
+  add_definitions(-DPY_VIEWER)
   list(APPEND SHARED_SOURCES "py_igl_viewer.cpp")
+endif ()
 
-endif (OPENGL_FOUND)
-# include comiso if available
-
-find_package(LIBCOMISOH QUIET)
-
-#Compile CoMISo (if found)
-# NOTE: this cmakefile works only with the
-# comiso available here: https://github.com/libigl/CoMISo
-IF(LIBCOMISO_FOUND)
-
+if (LIBIGL_WITH_COMISO)
   add_definitions(-DPY_COMISO)
-  list(APPEND SHARED_SOURCES "py_igl_comiso.cpp")
+  list(APPEND SHARED_SOURCES "copyleft/py_igl_comiso.cpp")
+endif ()
 
-  list(GET LIBCOMISO_INCLUDE_DIRS 0 COMISO_ROOT)
-  # message( FATAL_ERROR "${COMISO_ROOT}" )
-
-  if(APPLE)
-    find_library(accelerate_library Accelerate)
-    list(APPEND SHARED_LIBRARIES "CoMISo" ${accelerate_library})
-  elseif(UNIX)
-    find_package(BLAS REQUIRED)
-    list(APPEND SHARED_LIBRARIES "CoMISo" ${BLAS_LIBRARIES})
-  endif(APPLE)
-
-  if(MSVC)
-    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_SCL_SECURE_NO_DEPRECATE")
-    #link_directories("${COMISO_ROOT}/CoMISo/ext/OpenBLAS-v0.2.14-Win64-int64/lib/")
-    list(APPEND SHARED_LIBRARIES "CoMISo" "${COMISO_ROOT}/CoMISo/ext/OpenBLAS-v0.2.14-Win64-int64/lib/libopenblas.dll.a.lib")
-  endif(MSVC)
-
-
-  include_directories("${COMISO_ROOT}/CoMISo/ext/gmm-4.2/include")
-  include_directories("${COMISO_ROOT}/")
-  add_subdirectory("${COMISO_ROOT}/CoMISo/" "CoMISo")
-
-  if(MSVC)
-    # Copy the dll
-    add_custom_target(Copy-CoMISo-DLL        # Adds a post-build event to MyTest
-    COMMAND ${CMAKE_COMMAND} -E copy_if_different
-        "${COMISO_ROOT}/CoMISo/ext/OpenBLAS-v0.2.14-Win64-int64/bin/libopenblas.dll"
-        "${CMAKE_CURRENT_BINARY_DIR}/libopenblas.dll"
-    COMMAND ${CMAKE_COMMAND} -E copy_if_different
-        "${COMISO_ROOT}/CoMISo/ext/OpenBLAS-v0.2.14-Win64-int64/bin/libgcc_s_seh-1.dll"
-        "${CMAKE_CURRENT_BINARY_DIR}/libgcc_s_seh-1.dll"
-    COMMAND ${CMAKE_COMMAND} -E copy_if_different
-        "${COMISO_ROOT}/CoMISo/ext/OpenBLAS-v0.2.14-Win64-int64/bin/libgfortran-3.dll"
-        "${CMAKE_CURRENT_BINARY_DIR}/libgfortran-3.dll"
-    COMMAND ${CMAKE_COMMAND} -E copy_if_different
-        "${COMISO_ROOT}/CoMISo/ext/OpenBLAS-v0.2.14-Win64-int64/bin/libquadmath-0.dll"
-        "${CMAKE_CURRENT_BINARY_DIR}/libquadmath-0.dll")
-  endif(MSVC)
-
-ENDIF(LIBCOMISO_FOUND)
 
+## Prepare the python library
 add_library(igl SHARED
-  python.cpp
+  python_shared.cpp
   py_vector.cpp
   py_igl.cpp
   py_doc.cpp
   ${SHARED_SOURCES}
 )
 
-# if(NOT APPLE)
-# 	find_package(GLEW REQUIRED)
-# endif(NOT APPLE)
-
-if(APPLE)
-	set(CMAKE_SHARED_LINKER_FLAGS "-framework OpenGL -framework Cocoa")
-endif (APPLE) #APPLE
-
-
 set_target_properties(igl PROPERTIES PREFIX "")
 set_target_properties(igl PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR})
 
-target_link_libraries(igl ${SHARED_LIBRARIES})
+target_link_libraries(igl ${LIBIGL_LIBRARIES} ${LIBIGL_EXTRA_LIBRARIES})
 
 if (WIN32)
   if (MSVC)

+ 3 - 3
python/py_igl_comiso.cpp → python/copyleft/py_igl_comiso.cpp

@@ -3,7 +3,7 @@
 #include <Eigen/Sparse>
 
 
-#include "python.h"
+#include "../python_shared.h"
 
 #include <igl/copyleft/comiso/nrosy.h>
 #include <igl/copyleft/comiso/miq.h>
@@ -13,7 +13,7 @@ void python_export_igl_comiso(py::module &me) {
   py::module m = me.def_submodule(
     "comiso", "Wrappers for libigl functions that use comiso");
 
-  #include "py_igl/copyleft/comiso/py_nrosy.cpp"
-  #include "py_igl/copyleft/comiso/py_miq.cpp"
+  #include "../py_igl/copyleft/comiso/py_nrosy.cpp"
+  #include "../py_igl/copyleft/comiso/py_miq.cpp"
 
 }

+ 1 - 1
python/py_igl.cpp

@@ -1,6 +1,6 @@
 #include <Eigen/Dense>
 
-#include "python.h"
+#include "python_shared.h"
 
 #include <igl/readOFF.h>
 #include <igl/writeOBJ.h>

+ 0 - 0
python/py_igl/comiso/py_miq.cpp → python/py_igl/copyleft/comiso/py_miq.cpp


+ 0 - 0
python/py_igl/comiso/py_nrosy.cpp → python/py_igl/copyleft/comiso/py_nrosy.cpp


+ 1 - 1
python/py_igl_viewer.cpp

@@ -1,7 +1,7 @@
 #include <Eigen/Dense>
 #include <Eigen/Sparse>
 
-#include "python.h"
+#include "python_shared.h"
 #define ENABLE_SERIALIZATION
 #include <igl/viewer/Viewer.h>
 #include <igl/viewer/ViewerCore.h>

+ 1 - 1
python/py_vector.cpp

@@ -3,7 +3,7 @@
 #include <Eigen/Sparse>
 
 
-#include "python.h"
+#include "python_shared.h"
 
 /// Creates Python bindings for a dynamic Eigen matrix
 template <typename Type>

+ 1 - 1
python/python.cpp → python/python_shared.cpp

@@ -1,4 +1,4 @@
-#include "python.h"
+#include "python_shared.h"
 #include <sstream>
 #include <string>
 #include <fstream>

+ 0 - 0
python/python.h → python/python_shared.h


+ 1 - 1
tutorial/CMakeLists.txt

@@ -15,7 +15,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
 
 
 ### libIGL options: choose between header only and compiled static library
-option(LIBIGL_USE_STATIC_LIBRARY "Use LibIGL as static library" OFF)
+option(LIBIGL_USE_STATIC_LIBRARY "Use LibIGL as static library" ON)
 option(LIBIGL_WITH_VIEWER      "Use Viewer Nanogui Bar" ON)
 
 ### libIGL options: choose your dependencies (by default everything is OFF, in this example we need the viewer) ###