-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
63 lines (47 loc) · 1.67 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
# Copyright (c) Minmin Gong. All rights reserved.
# Licensed under the MIT License.
cmake_minimum_required(VERSION 3.18)
set(NR_MAJOR_VERSION 0)
set(NR_MINOR_VERSION 1)
set(NR_PATCH_VERSION 0)
set(NR_VERSION ${NR_MAJOR_VERSION}.${NR_MINOR_VERSION}.${NR_PATCH_VERSION})
project(NanoRtti VERSION "${NR_VERSION}" LANGUAGES CXX)
option(NANO_RTTI_BUILD_TESTS "Build tests of NanoRtti" ON)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(NR_CLANGFORMAT)
find_program(clang_format
NAMES
clang-format-10
clang-format
)
if(${clang_format} STREQUAL "CLANG_FORMAT-NOTFOUND")
message(FATAL_ERROR "No clang-format tool found")
endif()
message(STATUS "Generating clang-format target using ${clang_format}")
file(GLOB_RECURSE all_source_files *.cpp *.h *.hpp)
add_custom_target(clang_format
COMMAND ${clang_format} -i ${all_source_files}
COMMENT "Formatting with ${clang_format} ..."
)
return()
endif()
add_library(NanoRtti INTERFACE)
target_include_directories(NanoRtti INTERFACE Include)
if(CMAKE_GENERATOR MATCHES "Visual Studio")
set(nano_rtti_files
Include/NanoRtti/NanoRtti.hpp
Include/NanoRtti/Detail/Detail.hpp
)
source_group(TREE ${PROJECT_SOURCE_DIR}/Include FILES ${nano_rtti_files} PREFIX "Header Files")
target_sources(NanoRtti
PRIVATE
${nano_rtti_files}
)
endif()
if (NANO_RTTI_BUILD_TESTS)
add_subdirectory(Test)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT "Test")
endif()