-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
106 lines (89 loc) · 2.88 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# GLOBAL #
cmake_minimum_required(VERSION 3.15)
# Vcpkg
if(DEFINED CMAKE_TOOLCHAIN_FILE)
if(EXISTS "${CMAKE_TOOLCHAIN_FILE}")
message(STATUS "Vcpkg has been found")
else()
message(FATAL_ERROR "Vcpkg can't be found, CMake will exit")
endif()
else()
if(EXISTS "${CMAKE_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake")
message(STATUS "Vcpkg has been found")
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake" CACHE FILEPATH "CMAKE Toolchain" FORCE)
else()
message(FATAL_ERROR "Vcpkg can't be found, CMake will exit")
endif()
endif()
# Vcpkg triplet
if(WIN32)
if("${CMAKE_SIZEOF_VOID_P}" EQUAL 4)
message(FATAL_ERROR "VCPKG : windows:x86 triplet is not supported, CMake will exit")
elseif("${CMAKE_SIZEOF_VOID_P}" EQUAL 8)
set(VCPKG_TARGET_TRIPLET "x64-windows" CACHE STRING "VCPKG Triplet" FORCE)
endif()
elseif(UNIX)
if("${CMAKE_SIZEOF_VOID_P}" EQUAL 4)
message(FATAL_ERROR "VCPKG : linux:x86 triplet is not supported, CMake will exit.")
elseif("${CMAKE_SIZEOF_VOID_P}" EQUAL 8)
set(VCPKG_TARGET_TRIPLET "x64-linux" CACHE STRING "VCPKG Triplet" FORCE)
endif()
endif()
# ISPC
if(DEFINED ISPC_EXECUTABLE)
if(EXISTS "${ISPC_EXECUTABLE}")
message(STATUS "Found ISPC executable : ${ISPC_EXECUTABLE}")
else()
message(FATAL_ERROR "ISPC can't be found, CMake will exit")
endif()
else()
find_program(ISPC_EXECUTABLE ispc)
if(NOT ISPC_EXECUTABLE)
message(FATAL_ERROR "ISPC can't be found, CMake will exit")
else()
message(STATUS "Found ISPC executable : ${ISPC_EXECUTABLE}")
endif()
endif()
# Linux stdlib
if(UNIX)
set(CMAKE_CXX_STANDARD_LIBRARIES "-ldl")
endif()
# Project
project(RomanoRender2)
# CPP Standard
set(CMAKE_CXX_STANDARD 17)
# Compile and link options
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
add_compile_definitions(-D_CRT_SECURE_NO_WARNINGS -D__AVX2__)
set(MSVC_COMPILER_FLAGS "/fp:fast /Ox /Os /Oy /GT /GL /Oi /arch:AVX2 /Zi /Gm- /Zc:inline /Qpar")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" "${MSVC_COMPILER_FLAGS}")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options(-fopenmp -O3 -mavx2 -mf16c -fpermissive)
add_link_options(-lstdc++fs)
else()
message(FATAL_ERROR "Your compiler is not supported yet, CMake will exit.")
endif()
# Embree
find_package(embree 3 REQUIRED)
include_directories(${EMBREE_INCLUDE_DIRS})
# OpenImageIO
find_package(OpenImageIO REQUIRED)
include_directories(${OpenImageIO_INCLUDE_DIRS})
# Tbb
find_package(tbb REQUIRED)
# OSL
# Pugixml required by osl
find_package(pugixml REQUIRED)
set(OSL_INCLUDE_DIRS dependencies/osl/include)
include_directories(${OSL_INCLUDE_DIRS})
# ImGui / ImNodes / ImFileDialog / GLFW
set(IMGUI_INCLUDES dependencies/imgui
dependencies/imnodes
dependencies/imfiledialog
dependencies/glfw/include)
include_directories(${IMGUI_INCLUDES})
# Subdirs
add_subdirectory(dependencies)
# Src
include_directories(src)
add_subdirectory(src)