diff --git a/CMakeLists.txt b/CMakeLists.txt index 712fb1d..440a63a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,9 @@ PROJECT ( OpenVDB ) ENABLE_TESTING() +OPTION ( OPENVDB_BUILD_TOOLS "Build OpenVDB utilities" ON ) +OPTION ( OPENVDB_STATIC "Build statically linked library" ON ) +OPTION ( OPENVDB_SHARED "Build dynamically linked library" ON ) OPTION ( OPENVDB_BUILD_UNITTESTS "Build the OpenVDB unit tests" ON ) OPTION ( OPENVDB_BUILD_DOCS "Build the OpenVDB documentation" OFF ) OPTION ( OPENVDB_BUILD_PYTHON_MODULE "Build the pyopenvdb Python module" ON ) diff --git a/openvdb/CMakeLists.txt b/openvdb/CMakeLists.txt index 5703eb9..6ff3c6a 100644 --- a/openvdb/CMakeLists.txt +++ b/openvdb/CMakeLists.txt @@ -26,6 +26,7 @@ # PROJECT ( OpenVDBCore ) +IF ( OPENVDB_BUILD_TOOLS ) IF ( USE_GLFW3 ) FIND_PACKAGE ( GLFW3 REQUIRED ) SET ( OPENVDB_USE_GLFW_FLAG "-DOPENVDB_USE_GLFW_3" ) @@ -42,9 +43,12 @@ ELSE () SET ( GLFW_LINK_LIBRARY ${GLFW_glfw_LIBRARY} ) SET ( GLFW_INCLUDE_DIRECTORY ${GLFW_INCLUDE_DIR} CACHE STRING "GLFW include directory") ENDIF () +ENDIF ( OPENVDB_BUILD_TOOLS ) IF (WIN32) + IF ( OPENVDB_BUILD_TOOLS ) FIND_PACKAGE ( GLEW REQUIRED ) + ENDIF ( OPENVDB_BUILD_TOOLS ) ELSE () FIND_PACKAGE ( Threads REQUIRED ) ENDIF() @@ -75,7 +79,7 @@ SET ( OPENVDB_PATCH_VERSION_NUMBER ${_openvdb_patch_version_number} CACHE STRING # MESSAGE ( "OPENVDB_MINOR_VERSION_NUMBER = ${OPENVDB_MINOR_VERSION_NUMBER}" ) # MESSAGE ( "OPENVDB_PATCH_VERSION_NUMBER = ${OPENVDB_PATCH_VERSION_NUMBER}" ) -FIND_PACKAGE ( Boost ${MINIMUM_BOOST_VERSION} REQUIRED COMPONENTS iostreams system thread ${OPENVDB_BOOST_PYTHON_LIBRARY_COMPONENT_NAME} ) +FIND_PACKAGE ( Boost ${MINIMUM_BOOST_VERSION} REQUIRED COMPONENTS iostreams system thread date_time ${OPENVDB_BOOST_PYTHON_LIBRARY_COMPONENT_NAME} ) IF (WIN32 AND OPENVDB_DISABLE_BOOST_IMPLICIT_LINKING) ADD_DEFINITIONS ( -DBOOST_ALL_NO_LIB ) ENDIF () @@ -85,7 +89,9 @@ FIND_PACKAGE ( TBB REQUIRED ) FIND_PACKAGE ( ZLIB REQUIRED ) FIND_PACKAGE ( ILMBase REQUIRED ) FIND_PACKAGE ( OpenEXR REQUIRED ) +IF ( OPENVDB_BUILD_TOOLS ) FIND_PACKAGE ( OpenGL REQUIRED ) +ENDIF () IF (OPENVDB_BUILD_DOCS) FIND_PACKAGE ( Doxygen REQUIRED ) ENDIF () @@ -127,7 +133,10 @@ INCLUDE_DIRECTORIES ( SYSTEM ${BLOSC_INCLUDE_DIR} ) INCLUDE_DIRECTORIES ( SYSTEM ${CPPUNIT_INCLUDE_DIR} ) IF (WIN32) - ADD_DEFINITIONS ( -D_WIN32 -DNOMINMAX -DHALF_EXPORTS -DOPENVDB_DLL ) + ADD_DEFINITIONS ( -D_WIN32 -DNOMINMAX ) + IF ( OPENVDB_SHARED ) + ADD_DEFINITIONS ( -DOPENVDB_DLL ) + ENDIF () ELSE () ADD_DEFINITIONS ( -pthread -fPIC ) ENDIF () @@ -167,16 +176,20 @@ SET ( OPENVDB_LIBRARY_SOURCE_FILES SET_SOURCE_FILES_PROPERTIES ( ${OPENVDB_LIBRARY_SOURCE_FILES} PROPERTIES - COMPILE_FLAGS "-DOPENVDB_PRIVATE -DOPENVDB_USE_BLOSC ${OPENVDB_USE_GLFW_FLAG}" + COMPILE_FLAGS "-DOPENVDB_PRIVATE -DOPENVDB_USE_BLOSC ${OPENVDB_USE_GLFW_FLAG} $<$:/bigobj>" ) - +IF ( OPENVDB_STATIC ) ADD_LIBRARY ( openvdb_static STATIC ${OPENVDB_LIBRARY_SOURCE_FILES} ) +ENDIF () +IF ( OPENVDB_SHARED ) ADD_LIBRARY ( openvdb_shared SHARED ${OPENVDB_LIBRARY_SOURCE_FILES} ) +ENDIF () +IF ( OPENVDB_STATIC ) TARGET_LINK_LIBRARIES ( openvdb_static ${Boost_IOSTREAMS_LIBRARY} ${Boost_SYSTEM_LIBRARY} @@ -185,6 +198,8 @@ TARGET_LINK_LIBRARIES ( openvdb_static ${ZLIB_LIBRARY} ${BLOSC_blosc_LIBRARY} ) +ENDIF () +IF ( OPENVDB_SHARED ) TARGET_LINK_LIBRARIES ( openvdb_shared ${Boost_IOSTREAMS_LIBRARY} ${Boost_SYSTEM_LIBRARY} @@ -193,7 +208,9 @@ TARGET_LINK_LIBRARIES ( openvdb_shared ${ZLIB_LIBRARY} ${BLOSC_blosc_LIBRARY} ) +ENDIF () +IF ( OPENVDB_STATIC ) IF (WIN32) SET_TARGET_PROPERTIES ( openvdb_static PROPERTIES OUTPUT_NAME libopenvdb @@ -203,7 +220,9 @@ ELSE() PROPERTIES OUTPUT_NAME openvdb ) ENDIF() +ENDIF () +IF ( OPENVDB_SHARED ) SET_TARGET_PROPERTIES( openvdb_shared PROPERTIES @@ -211,13 +230,15 @@ SET_TARGET_PROPERTIES( SOVERSION ${OPENVDB_MAJOR_VERSION_NUMBER}.${OPENVDB_MINOR_VERSION_NUMBER} VERSION ${OPENVDB_MAJOR_VERSION_NUMBER}.${OPENVDB_MINOR_VERSION_NUMBER}.${OPENVDB_PATCH_VERSION_NUMBER} ) +ENDIF () SET ( VDB_PRINT_SOURCE_FILES cmd/openvdb_print/main.cc ) SET_SOURCE_FILES_PROPERTIES ( ${VDB_PRINT_SOURCE_FILES} PROPERTIES - COMPILE_FLAGS "-DOPENVDB_USE_BLOSC ${OPENVDB_USE_GLFW_FLAG}" + COMPILE_FLAGS "-DOPENVDB_USE_BLOSC ${OPENVDB_USE_GLFW_FLAG} $<$:/bigobj>" ) +IF ( OPENVDB_BUILD_TOOLS ) ADD_EXECUTABLE ( vdb_print ${VDB_PRINT_SOURCE_FILES} ) @@ -231,7 +252,7 @@ TARGET_LINK_LIBRARIES ( vdb_print SET ( VDB_RENDER_SOURCE_FILES cmd/openvdb_render/main.cc ) SET_SOURCE_FILES_PROPERTIES ( ${VDB_RENDER_SOURCE_FILES} PROPERTIES - COMPILE_FLAGS "-DOPENVDB_USE_BLOSC ${OPENVDB_USE_GLFW_FLAG}" + COMPILE_FLAGS "-DOPENVDB_USE_BLOSC ${OPENVDB_USE_GLFW_FLAG} $<$:/bigobj>" ) ADD_EXECUTABLE ( vdb_render ${VDB_RENDER_SOURCE_FILES} @@ -256,26 +277,26 @@ SET ( VDB_VIEW_SOURCE_FILES ) SET_SOURCE_FILES_PROPERTIES ( ${VDB_VIEW_SOURCE_FILES} PROPERTIES - COMPILE_FLAGS "-DOPENVDB_USE_BLOSC ${OPENVDB_USE_GLFW_FLAG} -DGL_GLEXT_PROTOTYPES=1" + COMPILE_FLAGS "-DOPENVDB_USE_BLOSC ${OPENVDB_USE_GLFW_FLAG} -DGL_GLEXT_PROTOTYPES=1 $<$:/bigobj>" ) -IF (NOT WIN32) ADD_EXECUTABLE ( vdb_view ${VDB_VIEW_SOURCE_FILES} ) TARGET_LINK_LIBRARIES ( vdb_view openvdb_shared - ${Boost_THREAD_LIBRARY} + ${Boost_LIBRARIES} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} - ${COCOA_LIBRARY} - ${IOKIT_LIBRARY} - ${COREVIDEO_LIBRARY} + #${COCOA_LIBRARY} + #${IOKIT_LIBRARY} + #${COREVIDEO_LIBRARY} ${GLFW_LINK_LIBRARY} ${GLFW_DEPENDENT_LIBRARIES} ${GLEW_GLEW_LIBRARY} ) -ENDIF () + +ENDIF ( OPENVDB_BUILD_TOOLS ) SET ( UNITTEST_SOURCE_FILES unittest/main.cc @@ -405,27 +426,32 @@ IF (OPENVDB_BUILD_DOCS) ENDIF () +IF ( OPENVDB_BUILD_TOOLS ) # Installation -IF ( NOT WIN32 ) +#IF ( NOT WIN32 ) INSTALL ( TARGETS vdb_view DESTINATION bin ) -ENDIF () +#ENDIF () INSTALL ( TARGETS vdb_print vdb_render DESTINATION bin ) +ENDIF ( OPENVDB_BUILD_TOOLS ) +IF ( OPENVDB_STATIC) INSTALL ( TARGETS openvdb_static DESTINATION lib ) +ENDIF () +IF ( OPENVDB_SHARED ) IF (WIN32) INSTALL ( TARGETS openvdb_shared @@ -439,6 +465,7 @@ ELSE() lib ) ENDIF () +ENDIF ( OPENVDB_SHARED ) INSTALL ( DIRECTORY ${PROJECT_SOURCE_DIR} DESTINATION include FILES_MATCHING PATTERN "*.h"