From dc0fa6a26b436362fc1fdd13d1ba8850865634c7 Mon Sep 17 00:00:00 2001 From: Edgar Velazquez-Armendariz Date: Tue, 26 Feb 2013 17:43:51 -0500 Subject: [PATCH] Added some initial configuration flags in CMake for gcc/clang --- CMakeLists.txt | 8 ++++--- data/cmake/MitsubaBuildOptions.cmake | 34 ++++++++++++---------------- data/cmake/MitsubaExternal.cmake | 20 ++++++++++++++++ 3 files changed, 39 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c3e42be..cbe39073 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,12 +47,14 @@ else() message(STATUS "mitsuba ${MTS_VERSION} (${MTS_DATE})") endif() +# Setup the build options +include (MitsubaBuildOptions) + # Find the external libraries and setup the paths include (MitsubaExternal) -# Setup the build options, include paths and compile definitions -include (MitsubaBuildOptions) - +# Main mitsuba include directory +include_directories("include") # ===== Prerequisite resources ===== diff --git a/data/cmake/MitsubaBuildOptions.cmake b/data/cmake/MitsubaBuildOptions.cmake index 6a36aabb..7aae4210 100644 --- a/data/cmake/MitsubaBuildOptions.cmake +++ b/data/cmake/MitsubaBuildOptions.cmake @@ -6,15 +6,17 @@ 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) +# Default initial compiler flags which may be modified by advanced users +if (MTS_CMAKE_INIT) + set(MTS_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") + set(MTS_CXX_FLAGS "-fvisibility=hidden -pipe -march=nocona -mfpmath=sse -ffast-math -Wall -Winvalid-pch") + endif() + if (MTS_CXX_FLAGS) + set(CMAKE_CXX_FLAGS "${MTS_CXX_FLAGS} ${CMAKE_CXX_FLAGS}" CACHE + STRING "Flags used by the compiler during all build types." FORCE) + set(MTS_CXX_FLAGS) + endif() endif() # Top level configuration definitions @@ -107,15 +109,7 @@ endif() 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}) +if (MSVC AND MTS_SSE AND NOT CMAKE_CL_64) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:SSE2") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE2") endif() diff --git a/data/cmake/MitsubaExternal.cmake b/data/cmake/MitsubaExternal.cmake index 621e317a..acfbf98c 100644 --- a/data/cmake/MitsubaExternal.cmake +++ b/data/cmake/MitsubaExternal.cmake @@ -244,3 +244,23 @@ CMAKE_DEPENDENT_OPTION(BUILD_PYTHON "Build the Python bindings." ON if (PYTHONLIBS_FOUND AND mts_boost_PYTHON_FOUND) set (PYTHON_FOUND TRUE) endif () + + +# 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() + +# 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()