132 lines
3.3 KiB
CMake
132 lines
3.3 KiB
CMake
cmake_minimum_required(VERSION 3.18)
|
|
project("Simple Raytracer" C)
|
|
|
|
OPTION(BUILD_BENCHMARKS "Build and run benchmarks" OFF)
|
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
message( "CMAKE_BUILD_TYPE unset, forcing Debug" )
|
|
set(CMAKE_BUILD_TYPE "Debug")
|
|
endif()
|
|
|
|
set(CMAKE_C_STANDARD 11)
|
|
|
|
OPTION (USE_AVX2 "Use AVX2" OFF)
|
|
IF(USE_AVX2)
|
|
add_compile_options(-mavx2)
|
|
ENDIF()
|
|
|
|
add_compile_options(-Wall -Wextra -pedantic -Werror -fno-omit-frame-pointer)
|
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
|
|
OPTION (USE_OpenMP "Use OpenMP" ON)
|
|
|
|
if (CMAKE_BUILD_TYPE MATCHES Debug)
|
|
add_compile_options(--coverage)
|
|
add_link_options(--coverage)
|
|
message( "Forcing OpenMP off for Debug build" )
|
|
set( USE_OpenMP OFF )
|
|
endif()
|
|
|
|
IF(USE_OpenMP)
|
|
FIND_PACKAGE(OpenMP REQUIRED)
|
|
IF(OPENMP_C_FOUND)
|
|
add_compile_options(${OpenMP_C_FLAGS})
|
|
add_link_options(${OpenMP_C_FLAGS})
|
|
ENDIF()
|
|
ENDIF()
|
|
|
|
#jemalloc seems to be quite a bit faster
|
|
OPTION (USE_jemalloc "Use jemalloc" OFF)
|
|
if (USE_jemalloc)
|
|
find_package(PkgConfig REQUIRED )
|
|
if (PKGCONFIG_FOUND)
|
|
pkg_check_modules (JEMALLOC jemalloc)
|
|
pkg_search_module(JEMALLOC jemalloc)
|
|
if (JEMALLOC_FOUND)
|
|
include_directories(${JEMALLOC_INCLUDE_DIRS})
|
|
link_directories(${JEMALLOC_LIBRARY_DIRS})
|
|
link_libraries(${JEMALLOC_LIBRARIES})
|
|
else()
|
|
error( "Could not find jemalloc" )
|
|
endif()
|
|
endif()
|
|
endif()
|
|
|
|
find_package( Doxygen )
|
|
if ( DOXYGEN_FOUND )
|
|
set( DOXYGEN_EXCLUDE_PATTERNS
|
|
*/test/*
|
|
*/demo/*
|
|
*/external/*
|
|
*/main/*
|
|
*/benchmark/*)
|
|
|
|
set( DOXYGEN_OUTPUT_DIRECTORY doxygen )
|
|
set( DOXYGEN_EXTRACT_ALL YES )
|
|
set( DOXYGEN_OPTIMIZE_OUTPUT_FOR_C YES )
|
|
|
|
doxygen_add_docs( doxygen "${CMAKE_CURRENT_SOURCE_DIR}" )
|
|
else()
|
|
message( "Doxygen need to be installed to generate the doxygen documentation" )
|
|
endif()
|
|
|
|
#find_package(PythonLibs)
|
|
#if (PythonLibs_FOUND)
|
|
# include_directories(${PYTHON_INCLUDE_PATH})
|
|
#else()
|
|
# message(WARNING "PythonLibs not found")
|
|
#endif()
|
|
|
|
#find_package(PerlLibs)
|
|
#if (PerlLibs_FOUND)
|
|
# include_directories(${PERL_INCLUDE_PATH})
|
|
#else()
|
|
# message(WARNING "PerlLibs not found")
|
|
#endif()
|
|
|
|
add_definitions(-DUNITY_INCLUDE_DOUBLE -DUNITY_DOUBLE_PRECISION=0.0001f -DUNITY_INCLUDE_EXEC_TIME)
|
|
|
|
add_subdirectory(external)
|
|
|
|
add_subdirectory(module_math)
|
|
add_subdirectory(module_datastructures)
|
|
add_subdirectory(module_raytracer)
|
|
add_subdirectory(module_shapes)
|
|
add_subdirectory(module_patterns)
|
|
add_subdirectory(module_utilities)
|
|
|
|
find_package(SWIG 4.0 OPTIONAL_COMPONENTS python perl5)
|
|
if (SWIG_FOUND)
|
|
message("SWIG found: ${SWIG_EXECUTABLE}")
|
|
include (UseSWIG)
|
|
if (SWIG_python_FOUND)
|
|
message("SWIG python bindings will be generated")
|
|
FIND_PACKAGE(PythonLibs)
|
|
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
|
|
else()
|
|
message(WARNING "SWIG python bindings cannot be generated")
|
|
endif()
|
|
if (SWIG_perl5_FOUND)
|
|
message("SWIG perl bindings will be generated")
|
|
FIND_PACKAGE(PerlLibs)
|
|
INCLUDE_DIRECTORIES(${PERL_INCLUDE_PATH})
|
|
else()
|
|
message(WARNING "SWIG perl bindings cannot be generated")
|
|
endif()
|
|
|
|
if (SWIG_perl5_FOUND OR SWIG_python_FOUND)
|
|
add_subdirectory(module_swig)
|
|
endif()
|
|
endif()
|
|
|
|
add_subdirectory(demo)
|
|
add_subdirectory(main)
|
|
|
|
include(CTest)
|
|
add_subdirectory(test)
|
|
|
|
IF(BUILD_BENCHMARKS)
|
|
add_subdirectory(benchmark)
|
|
ENDIF()
|