Skip to content

Commit

Permalink
Merge pull request #75 from tschw/cmake-stuff
Browse files Browse the repository at this point in the history
CMake: Silent `git diff` after the build, one-click GUI-based config, much cleanup & fixes
  • Loading branch information
Dade916 committed Mar 23, 2018
2 parents 41f45ca + 05f57fd commit 9e3d04a
Show file tree
Hide file tree
Showing 143 changed files with 552 additions and 24,094 deletions.
62 changes: 45 additions & 17 deletions CMakeLists.txt
Expand Up @@ -16,25 +16,57 @@
# limitations under the License.
################################################################################

MESSAGE(STATUS "CMAKE VERSION DETECTED " ${CMAKE_VERSION})
MESSAGE(STATUS "CMake version " ${CMAKE_VERSION} " detected")


################################################################################
#
# Check and configure cmake
#
################################################################################
# Fresh start

cmake_minimum_required(VERSION 3.0)
cmake_policy(VERSION 3.0)
#Remove the following when the version check is at least 2.8.4

# Remove the following when the version check is at least 2.8.4
SET(CMAKE_LEGACY_CYGWIN_WIN32 0)

project(LuxRays)
set(supported_build_variants "Debug" "Release")

# Detect whether we're using a single config or multi config generator and
# configure it:

unset(CMAKE_CONFIGURATION_TYPES CACHE)

# This boots up the generator:
enable_language(C)
enable_language(CXX)

if (CMAKE_CONFIGURATION_TYPES)

message(STATUS "Multi-config generator detected")

# Hard-wire supported configurations:

set(CMAKE_CONFIGURATION_TYPES
${supported_build_variants} CACHE INTERNAL "-" FORCE)
else()
message(STATUS "Single-config generator detected")

# For generators like make, cmake needs to know which variant to use
# so let's have a drop-down selector for it in the GUI:

# Don't over-configure
SET(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "limit configs" FORCE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build configuration")
set_property(
CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${supported_build_variants})

message(STATUS "Using build variant: " ${CMAKE_BUILD_TYPE})

endif()

# The following implicitly boots up the generator, so don't move it up:

project(LuxRays)

################################################################################
#
Expand All @@ -50,16 +82,6 @@ set(CMAKE_MODULE_PATH
"${LuxRays_SOURCE_DIR}/cmake/SpecializedConfig"
)

# When using single configuration generators like make
# cmake does need to know which of the possible configurations
# to generate
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "assure config" FORCE) # makes sure type is shown in cmake gui

message(STATUS "Building mode: " ${CMAKE_BUILD_TYPE})

INCLUDE(PlatformSpecific)
INCLUDE(Configuration)
INCLUDE(KernelPreprocess)
Expand Down Expand Up @@ -122,12 +144,18 @@ endif()
#
################################################################################

set(GENERATED_DIR "${CMAKE_BINARY_DIR}/generated")
set(GENERATED_INCLUDE_DIR "${GENERATED_DIR}/include")

file(MAKE_DIRECTORY ${GENERATED_INCLUDE_DIR})
include_directories(${GENERATED_INCLUDE_DIR})


add_subdirectory(src/luxrays)
add_subdirectory(src/slg)
add_subdirectory(src/luxcore)
add_subdirectory(src/pyluxcoretools)


################################################################################
#
# Samples
Expand Down
20 changes: 20 additions & 0 deletions Configuration.cmake
Expand Up @@ -116,6 +116,26 @@ SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY
"Single Directory for all binaries"
)

SET(custom_config_dir "cmake/SpecializedConfig")

SET(LUXRAYS_CUSTOM_CONFIG "" CACHE STRING
"Use custom configuration file in ${custom_config_dir}")

# Find all config files:
FILE(GLOB available_config_files
RELATIVE "${CMAKE_SOURCE_DIR}/${custom_config_dir}"
"${CMAKE_SOURCE_DIR}/${custom_config_dir}/*.cmake")

# Remove file extensions:
set(available_configs "")
MESSAGE(STATUS "Available custom configurations in ${custom_config_dir}:")
FOREACH (config_file ${available_config_files})
GET_FILENAME_COMPONENT(config_name ${config_file} NAME_WE)
MESSAGE(STATUS " " ${config_name})
LIST(APPEND available_configs ${config_name})
ENDFOREACH()
SET_PROPERTY(CACHE LUXRAYS_CUSTOM_CONFIG PROPERTY STRINGS ${available_configs})

#
# Overwrite defaults with Custom Settings
#
Expand Down
16 changes: 7 additions & 9 deletions cmake/Dependencies.cmake
Expand Up @@ -43,9 +43,14 @@ if(NOT APPLE)
find_package(PNG REQUIRED)
include_directories(BEFORE SYSTEM ${PNG_PNG_INCLUDE_DIR})
# Find Python Libraries
find_package(PythonLibs)
find_package(PythonLibs 3.5)
endif()

find_program(PYSIDE_UIC NAME pyside-uic
HINTS "${PYTHON_INCLUDE_DIRS}/../Scripts"
PATHS "c:/Program Files/Python35/Scripts")


include_directories(${PYTHON_INCLUDE_DIRS})

# Find Boost
Expand All @@ -67,6 +72,7 @@ if (NOT Boost_FOUND)
else()
set(Boost_USE_STATIC_LIBS ON)
endif()
message(STATUS "Re-trying with link static = ${Boost_USE_STATIC_LIBS}")
find_package(Boost ${Boost_MINIMUM_VERSION} COMPONENTS ${LUXRAYS_BOOST_COMPONENTS})
endif()

Expand Down Expand Up @@ -127,17 +133,9 @@ endif()
# Find BISON
IF (NOT BISON_NOT_AVAILABLE)
find_package(BISON)
IF (NOT BISON_FOUND)
MESSAGE(WARNING "bison not found - try compilation using already generated files")
SET(BISON_NOT_AVAILABLE 1)
ENDIF (NOT BISON_FOUND)
ENDIF (NOT BISON_NOT_AVAILABLE)

# Find FLEX
IF (NOT FLEX_NOT_AVAILABLE)
find_package(FLEX)
IF (NOT FLEX_FOUND)
MESSAGE(WARNING "flex not found - try compilation using already generated files")
SET(FLEX_NOT_AVAILABLE 1)
ENDIF (NOT FLEX_FOUND)
ENDIF (NOT FLEX_NOT_AVAILABLE)
49 changes: 9 additions & 40 deletions cmake/KernelPreprocess.cmake
Expand Up @@ -25,46 +25,15 @@
FUNCTION(PreprocessOCLKernel NAMESPACE KERNEL SRC DST)
MESSAGE(STATUS "Preprocessing OpenCL kernel: " ${SRC} " => " ${DST} )

IF(WIN32)
add_custom_command(
OUTPUT ${DST}
COMMAND echo \#include ^<string^> > ${DST}
COMMAND echo namespace ${NAMESPACE} { namespace ocl { >> ${DST}
COMMAND echo std::string KernelSource_${KERNEL} = >> ${DST}

# need delayed expansion for the env variable
# so we can use the search/replace functionality when expanding env vars
# which for some reason doesn't work for loop vars
# however delayed expansion relies on ! keyword which causes "lone" !'s
# to get eaten in the first set statement
# so, enable after the initial set statement and disable when done

#COMMAND for /F \"usebackq tokens=*\" %%a in (${SRC}) do if \"%%a\"==\"\" (echo \"\\n\" >> ${DST}) else (set line=%%a&&set line=!line:\\=\\\\!&& echo \"!line:\"=\\\"!\\n\" >> ${DST})
COMMAND for /F \"usebackq tokens=*\" %%a in (${SRC}) do if \"%%a\"==\"\" (echo \"\\n\" >> ${DST}) else (
COMMAND set line=%%a
COMMAND setlocal ENABLEDELAYEDEXPANSION
# escape \
COMMAND set line=!line:\\=\\\\!
# escape "
COMMAND set line=!line:\"=\\\"!
# output processed line
COMMAND echo \"!line!\\n\" >> ${DST}
COMMAND endlocal
COMMAND )
COMMAND echo \; } } >> ${DST}
MAIN_DEPENDENCY ${SRC}
)
ELSE(WIN32)
add_custom_command(
OUTPUT ${DST}
COMMAND echo \"\#include <string>\" > ${DST}
COMMAND echo namespace ${NAMESPACE} \"{ namespace ocl {\" >> ${DST}
COMMAND echo "std::string KernelSource_${KERNEL} = " >> ${DST}
COMMAND cat ${SRC} | sed 's/\r//g' | sed 's/\\\\/\\\\\\\\/g' | sed 's/\"/\\\\\"/g' | awk '{ printf \(\"\\"%s\\\\n\\"\\n\", $$0\) }' >> ${DST}
COMMAND echo "\; } }" >> ${DST}
MAIN_DEPENDENCY ${SRC}
)
ENDIF(WIN32)
add_custom_command(
OUTPUT ${DST}
COMMAND ${CMAKE_COMMAND}
-DDST=${DST} -DSRC=${SRC}
-DNAMESPACE=${NAMESPACE} -DKERNEL=${KERNEL}
-P "${CMAKE_SOURCE_DIR}/cmake/Scripts/PreprocessKernel.cmake"
MAIN_DEPENDENCY ${SRC}
)

ENDFUNCTION(PreprocessOCLKernel)

FUNCTION(PreprocessOCLKernels)
Expand Down
2 changes: 1 addition & 1 deletion cmake/Packages/FindOpenEXR.cmake
Expand Up @@ -67,7 +67,7 @@ ENDFOREACH(i)
ENDIF(OPENEXR_INCLUDE_DIRS)

SET(OpenEXR_LIBRARY_MODULES Iex IlmImf Half Imath IlmThread)
SET(OpenEXR_LIB_SUFFIXES lib64 lib Lib lib/OpenEXR Libs)
SET(OpenEXR_LIB_SUFFIXES lib64 lib Lib lib/OpenEXR Libs x64/Release/lib)
SET(OpenEXR_LIB_SUFFIXES_REL)
SET(OpenEXR_LIB_SUFFIXES_DBG)
FOREACH(i ${OpenEXR_LIB_SUFFIXES})
Expand Down
2 changes: 1 addition & 1 deletion cmake/Packages/FindOpenImageIO.cmake
Expand Up @@ -51,7 +51,7 @@ FIND_LIBRARY(OPENIMAGEIO_LIBRARY
HINTS
${_openimageio_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
lib64 lib x64/Release/lib
)

# handle the QUIETLY and REQUIRED arguments and set OPENIMAGEIO_FOUND to TRUE if
Expand Down

0 comments on commit 9e3d04a

Please sign in to comment.