mirror of
https://github.com/ssloy/tinyraytracer.git
synced 2024-04-18 07:30:54 +08:00
41 lines
1.2 KiB
CMake
41 lines
1.2 KiB
CMake
cmake_minimum_required (VERSION 2.8)
|
|
project (tinyraytracer)
|
|
|
|
set(SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
set(LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib")
|
|
|
|
include(CheckCXXCompilerFlag)
|
|
function(enable_cxx_compiler_flag_if_supported flag)
|
|
string(FIND "${CMAKE_CXX_FLAGS}" "${flag}" flag_already_set)
|
|
if(flag_already_set EQUAL -1)
|
|
check_cxx_compiler_flag("${flag}" flag_supported)
|
|
if(flag_supported)
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" PARENT_SCOPE)
|
|
endif()
|
|
unset(flag_supported CACHE)
|
|
endif()
|
|
endfunction()
|
|
|
|
enable_cxx_compiler_flag_if_supported("-Wall")
|
|
enable_cxx_compiler_flag_if_supported("-Wextra")
|
|
enable_cxx_compiler_flag_if_supported("-pedantic")
|
|
enable_cxx_compiler_flag_if_supported("-std=c++11")
|
|
enable_cxx_compiler_flag_if_supported("-O3")
|
|
enable_cxx_compiler_flag_if_supported("-fopenmp")
|
|
|
|
|
|
file(GLOB SOURCES
|
|
"${SRC_DIR}/*.h"
|
|
"${SRC_DIR}/*.cpp"
|
|
)
|
|
|
|
# Executable definition and properties
|
|
add_executable(${PROJECT_NAME} ${SOURCES})
|
|
target_include_directories(${PROJECT_NAME} PRIVATE "${SRC_DIR}")
|
|
|
|
# STB
|
|
set(STB_DIR "${LIB_DIR}/stb")
|
|
target_include_directories(${PROJECT_NAME} PRIVATE "${STB_DIR}")
|
|
|
|
|