forked from vsg-dev/VulkanSceneGraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
144 lines (117 loc) · 5.21 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
cmake_minimum_required(VERSION 3.7)
project(VSG
VERSION 0.0.0
DESCRIPTION "VulkanSceneGraph library"
LANGUAGES CXX
)
set(VSG_SOVERSION 0)
# create the version header
set(VSG_MAX_DEVICES 1 CACHE STRING "Set maximum number of vk/vsg::Device that are supported.")
set(VSG_VERSION_HEADER "${PROJECT_BINARY_DIR}/include/vsg/core/Version.h")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/vsg/core/Version.h.in" "${VSG_VERSION_HEADER}")
set(OUTPUT_BINDIR ${PROJECT_BINARY_DIR}/bin)
set(OUTPUT_LIBDIR ${PROJECT_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_LIBDIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_LIBDIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_BINDIR})
SET(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually d on windows")
SET(CMAKE_RELEASE_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
SET(CMAKE_RELWITHDEBINFO_POSTFIX "rd" CACHE STRING "add a postfix, usually empty on windows")
SET(CMAKE_MINSIZEREL_POSTFIX "s" CACHE STRING "add a postfix, usually empty on windows")
if(WIN32)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_BINDIR})
# set up local bin directory to place all binaries
make_directory(${OUTPUT_BINDIR})
make_directory(${OUTPUT_LIBDIR})
else(WIN32)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_LIBDIR})
# set up local bin directory to place all binaries
make_directory(${OUTPUT_LIBDIR})
endif(WIN32)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_BINDIR})
# Change the default build type to Release
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif(NOT CMAKE_BUILD_TYPE)
if(CMAKE_COMPILER_IS_GNUCXX)
set(VSG_WARNING_FLAGS -Wall -Wparentheses -Wno-long-long -Wno-import -Wreturn-type -Wmissing-braces -Wunknown-pragmas -Wmaybe-uninitialized -Wshadow -Wunused -Wno-misleading-indentation -Wextra)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(VSG_WARNING_FLAGS -Wall -Wparentheses -Wno-long-long -Wno-import -Wreturn-type -Wmissing-braces -Wunknown-pragmas -Wshadow -Wunused -Wextra)
endif()
set(VSG_WARNING_FLAGS ${VSG_WARNING_FLAGS} CACHE STRING "Compiler flags to use." FORCE)
add_compile_options(${VSG_WARNING_FLAGS})
if (VULKAN_SDK)
message("Within VulkanSceneGraph cmake, setting VULKAN_SDK env var to " ${VULKAN_SDK})
set(ENV{VULKAN_SDK} ${VULKAN_SDK})
endif()
find_package(Vulkan)
find_package(Threads)
if (ANDROID)
find_library(AndroidLib android)
if(CMAKE_SYSTEM_VERSION GREATER 24)
find_library(AndroidNativeWindowLib nativewindow)
endif()
elseif (WIN32)
# just use native windowing
elseif (APPLE)
find_library(COCOA_LIBRARY Cocoa)
find_library(QUARTZCORE_LIBRARY QuartzCore)
else()
# just use Xcb for native windowing
find_package(PkgConfig)
pkg_check_modules(xcb REQUIRED IMPORTED_TARGET xcb)
endif()
# create doxygen build target
find_package(Doxygen QUIET)
if (DOXYGEN_FOUND)
set(DOXYGEN_GENERATE_HTML YES)
set(DOXYGEN_GENERATE_MAN NO)
doxygen_add_docs(
docs
${PROJECT_SOURCE_DIR}/include/vsg
COMMENT "Use doxygen to Generate html documentaion"
)
endif()
# add clobber build target to clear all the non git registered files/directories
add_custom_target(clobber
COMMAND git clean -d -f -x
)
# automatically buil_all_h build target to generate the include/vsg/all.h from the headers in the include/vsg/* directories
add_custom_target(build_all_h
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/build/build_all_h.cmake
)
# automatically buil_all_h build target to generate the include/vsg/all.h from the headers in the include/vsg/* directories
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/build/uninstall.cmake
)
# add cppcheck build target to provide static analysis of codebase
find_program(CPPCHECK cppcheck)
if (CPPCHECK)
file(RELATIVE_PATH PATH_TO_SOURCE ${PROJECT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} )
if (PATH_TO_SOURCE)
set(PATH_TO_SOURCE "${PATH_TO_SOURCE}/")
endif()
include(ProcessorCount)
ProcessorCount(CPU_CORES)
set(CPPCHECK_SUPPRESION_LIST_FILE "${CMAKE_SOURCE_DIR}/build/cppcheck-suppression-list.txt")
set(CPPCHECK_SUPPRESION_LIST "--suppressions-list=${CPPCHECK_SUPPRESION_LIST_FILE}")
set(CPPCHECK_EXTRA_OPTIONS "" CACHE STRING "additional commndline options to use when invoking cppcheck")
add_custom_target(cppcheck
COMMAND ${CPPCHECK} -j ${CPU_CORES} --quiet --enable=style --language=c++ ${CPPCHECK_EXTRA_OPTIONS} ${CPPCHECK_SUPPRESION_LIST} ${PATH_TO_SOURCE}include/vsg/*/*.h ${PATH_TO_SOURCE}src/vsg/*/*.cpp -I ${PATH_TO_SOURCE}include/
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Static code analysis using cppcheck"
)
endif()
# add clang-foramt build target to enforce a standard code style guide.
find_program(CLANGFORMAT clang-format)
if (CLANGFORMAT)
add_custom_target(clang-format
COMMAND ${CLANGFORMAT} -i ${PATH_TO_SOURCE}include/vsg/*/*.h ${PATH_TO_SOURCE}src/vsg/*/*.cpp
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Automated code format using clang-format"
)
endif()
#
# src directory contains all the source of the vsg library
#
add_subdirectory(src/vsg)