diff --git a/CMakeLists.txt b/CMakeLists.txt index ee55ae8f..7d38a80a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,133 +54,12 @@ else() endif() -########################### External libraries ################################ +# Find the external libraries and setup the paths include (MitsubaExternal) +# Setup the build options, include paths and compile definitions +include (MitsubaBuildOptions) -############################################################################### -# CONFIGURATION AND DEFAULT DEFINITIONS & INCLUDES # -############################################################################### - -# Image format definitions -if (PNG_FOUND) - add_definitions(-DMTS_HAS_LIBPNG=1) -endif() -if (JPEG_FOUND) - add_definitions(-DMTS_HAS_LIBJPEG=1) -endif() -if (OPENEXR_FOUND) - add_definitions(-DMTS_HAS_OPENEXR=1) -endif() - -# Top level configuration definitions -option(MTS_DEBUG "Enable assertions etc. Usually a good idea." ON) -if (MTS_DEBUG) - add_definitions(-DMTS_DEBUG) -endif() -option(MTS_KD_DEBUG "Enable additional checks in the kd-Tree. -This is quite slow and mainly useful to track down bugs when they are suspected." -OFF) -if (MTS_KD_DEBUG) - add_definitions(-DMTS_KD_DEBUG) -endif() -option(MTS_KD_CONSERVE_MEMORY - "Use less memory for storing geometry (at the cost of speed)." OFF) -if (MTS_KD_CONSERVE_MEMORY) - add_definitions(-DMTS_KD_CONSERVE_MEMORY) -endif() -option(MTS_SINGLE_PRECISION - "Do all computation in single precision. This is usually sufficient." ON) -if (MTS_SINGLE_PRECISION) - add_definitions(-DSINGLE_PRECISION) -endif() - -set(MTS_SPECTRUM_SAMPLES 3 CACHE STRING - "Number of spectral samples used to render. The default is 3 (RGB-mode). -For high-quality spectral rendering, this should be set to 30 or higher.") -if(NOT "${MTS_SPECTRUM_SAMPLES}" MATCHES "^[1-9][0-9]*$" OR - MTS_SPECTRUM_SAMPLES LESS 3 OR MTS_SPECTRUM_SAMPLES GREATER 2048) - message(FATAL_ERROR - "Invalid number of spectrum samples: ${MTS_SPECTRUM_SAMPLES}. Valid values: [3,2048]") -else() - add_definitions(-DSPECTRUM_SAMPLES=${MTS_SPECTRUM_SAMPLES}) -endif() - -CMAKE_DEPENDENT_OPTION (MTS_DOUBLE_PRECISION - "Do all computation in double precision." ON - "NOT MTS_SINGLE_PRECISION" OFF) -if (MTS_DOUBLE_PRECISION) - add_definitions(-DDOUBLE_PRECISION) -endif() - -CMAKE_DEPENDENT_OPTION (MTS_SSE "Activate optimized SSE routines." ON - "NOT MTS_DOUBLE_PRECISION" OFF) -if (MTS_SSE) - add_definitions(-DMTS_SSE) -endif () - -CMAKE_DEPENDENT_OPTION (MTS_HAS_COHERENT_RT - "Include coherent ray tracing support." ON - "MTS_SSE" OFF) -if (MTS_HAS_COHERENT_RT) - add_definitions(-DMTS_HAS_COHERENT_RT) -endif() - -CMAKE_DEPENDENT_OPTION (MTS_DEBUG_FP - "Generated NaNs will cause floating point exceptions, which can be caught in a debugger (very slow!)" OFF - "NOT MTS_DOUBLE_PRECISION" OFF) -if (MTS_DEBUG_FP) - add_definitions(-DMTS_DEBUG_FP) -endif() - - -# Options to disable MSVC STL debug + security features (slow..!) -if (MSVC OR (WIN32 AND CMAKE_C_COMPILER_ID MATCHES "Intel")) - # _SECURE_SCL already defaults to 0 in release mode in MSVC 2010 - if(MSVC_VERSION LESS 1600) - option(MTS_NO_CHECKED_ITERATORS "Disable checked iterators in MSVC" OFF) - option(MTS_NO_ITERATOR_DEBUGGING "Disable iterator debugging in MSVC" OFF) - else() - set(MTS_NO_CHECKED_ITERATORS OFF) - set(MTS_NO_ITERATOR_DEBUGGING OFF) - endif() - option(MTS_NO_BUFFER_CHECKS "Disable the buffer security checks in MSVC" ON) - - if (MTS_NO_ITERATOR_DEBUGGING) - add_definitions (-D_HAS_ITERATOR_DEBUGGING=0) - endif() - if (MTS_NO_CHECKED_ITERATORS OR MTS_NO_ITERATOR_DEBUGGING) - add_definitions (-D_SECURE_SCL=0 -D_SCL_SECURE_NO_WARNINGS) - message (WARNING "The secure iterators were manually disabled. There might be incompatibility problems.") - endif () - if (MTS_NO_BUFFER_CHECKS) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /GS-") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GS-") - endif() -endif() - -# Platform-specific definitions -if (WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 8) - add_definitions(-DWIN64) -endif() - - -# Main mitsuba include directory -include_directories("include") - -# Includes for the common libraries -include_directories(${Boost_INCLUDE_DIRS} ${Eigen_INCLUDE_DIR}) - -# If we are using the system OpenEXR, add its headers which half.h requires -if (OPENEXR_FOUND) - include_directories(${ILMBASE_INCLUDE_DIRS}) -endif() - - - -############################################################################### -# CORE MODULES, APPLICATIONS AND PLUGINS # -############################################################################### # ===== Prerequisite resources ===== @@ -213,6 +92,8 @@ endif() # Additional files to add to main executables if(APPLE) set(MTS_DARWIN_STUB "${CMAKE_CURRENT_SOURCE_DIR}/src/mitsuba/darwin_stub.mm") +else() + set(MTS_DARWIN_STUB "") endif() diff --git a/data/cmake/MitsubaBuildOptions.cmake b/data/cmake/MitsubaBuildOptions.cmake new file mode 100644 index 00000000..6a36aabb --- /dev/null +++ b/data/cmake/MitsubaBuildOptions.cmake @@ -0,0 +1,121 @@ +############################################################################### +# CONFIGURATION AND DEFAULT DEFINITIONS & INCLUDES # +############################################################################### + +if (NOT DEFINED MTS_VERSION) + message(FATAL_ERROR "This file has to be included from the main build file.") +endif() + +# Image format definitions +if (PNG_FOUND) + add_definitions(-DMTS_HAS_LIBPNG=1) +endif() +if (JPEG_FOUND) + add_definitions(-DMTS_HAS_LIBJPEG=1) +endif() +if (OPENEXR_FOUND) + add_definitions(-DMTS_HAS_OPENEXR=1) +endif() + +# Top level configuration definitions +option(MTS_DEBUG "Enable assertions etc. Usually a good idea." ON) +if (MTS_DEBUG) + add_definitions(-DMTS_DEBUG) +endif() +option(MTS_KD_DEBUG "Enable additional checks in the kd-Tree. +This is quite slow and mainly useful to track down bugs when they are suspected." +OFF) +if (MTS_KD_DEBUG) + add_definitions(-DMTS_KD_DEBUG) +endif() +option(MTS_KD_CONSERVE_MEMORY + "Use less memory for storing geometry (at the cost of speed)." OFF) +if (MTS_KD_CONSERVE_MEMORY) + add_definitions(-DMTS_KD_CONSERVE_MEMORY) +endif() +option(MTS_SINGLE_PRECISION + "Do all computation in single precision. This is usually sufficient." ON) +if (MTS_SINGLE_PRECISION) + add_definitions(-DSINGLE_PRECISION) +endif() + +set(MTS_SPECTRUM_SAMPLES 3 CACHE STRING + "Number of spectral samples used to render. The default is 3 (RGB-mode). +For high-quality spectral rendering, this should be set to 30 or higher.") +if(NOT "${MTS_SPECTRUM_SAMPLES}" MATCHES "^[1-9][0-9]*$" OR + MTS_SPECTRUM_SAMPLES LESS 3 OR MTS_SPECTRUM_SAMPLES GREATER 2048) + message(FATAL_ERROR + "Invalid number of spectrum samples: ${MTS_SPECTRUM_SAMPLES}. Valid values: [3,2048]") +else() + add_definitions(-DSPECTRUM_SAMPLES=${MTS_SPECTRUM_SAMPLES}) +endif() + +CMAKE_DEPENDENT_OPTION (MTS_DOUBLE_PRECISION + "Do all computation in double precision." ON + "NOT MTS_SINGLE_PRECISION" OFF) +if (MTS_DOUBLE_PRECISION) + add_definitions(-DDOUBLE_PRECISION) +endif() + +CMAKE_DEPENDENT_OPTION (MTS_SSE "Activate optimized SSE routines." ON + "NOT MTS_DOUBLE_PRECISION" OFF) +if (MTS_SSE) + add_definitions(-DMTS_SSE) +endif () + +CMAKE_DEPENDENT_OPTION (MTS_HAS_COHERENT_RT + "Include coherent ray tracing support." ON + "MTS_SSE" OFF) +if (MTS_HAS_COHERENT_RT) + add_definitions(-DMTS_HAS_COHERENT_RT) +endif() + +CMAKE_DEPENDENT_OPTION (MTS_DEBUG_FP + "Generated NaNs will cause floating point exceptions, which can be caught in a debugger (very slow!)" OFF + "NOT MTS_DOUBLE_PRECISION" OFF) +if (MTS_DEBUG_FP) + add_definitions(-DMTS_DEBUG_FP) +endif() + + +# Options to disable MSVC STL debug + security features (slow..!) +if (MSVC OR (WIN32 AND CMAKE_C_COMPILER_ID MATCHES "Intel")) + # _SECURE_SCL already defaults to 0 in release mode in MSVC 2010 + if(MSVC_VERSION LESS 1600) + option(MTS_NO_CHECKED_ITERATORS "Disable checked iterators in MSVC" OFF) + option(MTS_NO_ITERATOR_DEBUGGING "Disable iterator debugging in MSVC" OFF) + else() + set(MTS_NO_CHECKED_ITERATORS OFF) + set(MTS_NO_ITERATOR_DEBUGGING OFF) + endif() + option(MTS_NO_BUFFER_CHECKS "Disable the buffer security checks in MSVC" ON) + + if (MTS_NO_ITERATOR_DEBUGGING) + add_definitions (-D_HAS_ITERATOR_DEBUGGING=0) + endif() + if (MTS_NO_CHECKED_ITERATORS OR MTS_NO_ITERATOR_DEBUGGING) + add_definitions (-D_SECURE_SCL=0 -D_SCL_SECURE_NO_WARNINGS) + message (WARNING "The secure iterators were manually disabled. There might be incompatibility problems.") + endif () + if (MTS_NO_BUFFER_CHECKS) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /GS-") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GS-") + endif() +endif() + +# Platform-specific definitions +if (WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 8) + add_definitions(-DWIN64) +endif() + + +# Main mitsuba include directory +include_directories("include") + +# Includes for the common libraries +include_directories(${Boost_INCLUDE_DIRS} ${Eigen_INCLUDE_DIR}) + +# If we are using the system OpenEXR, add its headers which half.h requires +if (OPENEXR_FOUND) + include_directories(${ILMBASE_INCLUDE_DIRS}) +endif()