-
Notifications
You must be signed in to change notification settings - Fork 250
/
CMakeLists.txt
105 lines (87 loc) · 3.3 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
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
cmake_minimum_required(VERSION 3.9)
if(WIN32 AND (${CMAKE_GENERATOR} MATCHES "Visual Studio ([^9]|[9][0-9])") AND (NOT SC_CLANGFORMAT))
set(SC_WITH_CSHARP ON)
else()
set(SC_WITH_CSHARP OFF)
endif()
set(PROJECT_NAME ShaderConductor)
project(${PROJECT_NAME})
if(SC_WITH_CSHARP)
project(${PROJECT_NAME} LANGUAGES CSharp)
set(CMAKE_CSharp_FLAGS "/langversion:7")
endif()
set(SC_MAJOR_VERSION 0)
set(SC_MINOR_VERSION 3)
set(SC_PATCH_VERSION 0)
set(SC_VERSION ${SC_MAJOR_VERSION}.${SC_MINOR_VERSION}.${SC_PATCH_VERSION})
set(SC_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(SC_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
mark_as_advanced(SC_ROOT_DIR)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${SC_BUILD_DIR}/Bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${SC_BUILD_DIR}/Lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${SC_BUILD_DIR}/Lib)
if((CMAKE_C_COMPILER_ID MATCHES GNU) OR (CMAKE_C_COMPILER_ID MATCHES Clang))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z")
endif()
if (CMAKE_C_COMPILER_ID MATCHES Clang)
foreach(flagVar
CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
set(${flagVar} "${${flagVar}} -fms-extensions -Wno-language-extension-token")
endforeach()
endif()
set(Python_ADDITIONAL_VERSIONS 3.5 3.6 3.7 3.8)
if(SC_CLANGFORMAT)
find_program(CLANG_FORMAT
NAMES
clang-format-9
clang-format
)
if(${CLANG_FORMAT} STREQUAL "CLANG_FORMAT-NOTFOUND")
message(FATAL_ERROR "No clang-format tool found")
endif()
message(STATUS "Generating clangformat target using ${CLANG_FORMAT}")
file(GLOB_RECURSE ALL_SOURCE_FILES *.cpp *.h *.hpp)
add_custom_target(clangformat
COMMAND ${CLANG_FORMAT} -i ${ALL_SOURCE_FILES})
return()
endif()
# Handle a compiling issue of SPIR-V
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
if(CMAKE_C_COMPILER_ID MATCHES Clang)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()
foreach(flagVar
CMAKE_SHARED_LINKER_FLAGS_RELEASE CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL
CMAKE_MODULE_LINKER_FLAGS_RELEASE CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL
CMAKE_EXE_LINKER_FLAGS_RELEASE CMAKE_EXE_LINKER_FLAGS_MINSIZEREL)
set(${flagVar} "${${flagVar}} -s")
endforeach()
endif()
if(WIN32)
if(MSVC AND (CMAKE_GENERATOR MATCHES "^Visual Studio"))
if((CMAKE_GENERATOR_PLATFORM STREQUAL "x64") OR (CMAKE_GENERATOR MATCHES "Win64"))
set(SC_ARCH_NAME "x64")
elseif((CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64") OR (CMAKE_GENERATOR MATCHES "ARM64"))
set(SC_ARCH_NAME "arm64")
elseif((CMAKE_GENERATOR_PLATFORM STREQUAL "ARM") OR (CMAKE_GENERATOR MATCHES "ARM"))
set(SC_ARCH_NAME "arm")
else()
set(SC_ARCH_NAME "x86")
endif()
endif()
else()
if(NOT SC_ARCH_NAME)
if((CMAKE_SYSTEM_PROCESSOR MATCHES "AMD64") OR (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64"))
set(SC_ARCH_NAME "x64")
else()
set(SC_ARCH_NAME "x86")
endif()
endif()
endif()
add_subdirectory(Source)
add_subdirectory(External)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT "ShaderConductorCmd")