-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
45 lines (36 loc) · 1.51 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
cmake_minimum_required(VERSION 3.31.2)
project(ArtNetController)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "") # works
# Set a default build type if none is specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "RelWithDebInfo" "MinSizeRel")
endif()
# Set compiler to clang if available, otherwise use default
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message(STATUS "Using Clang compiler.")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weverything -Wno-c++98-compat -Wno-gnu-anonymous-struct -Wno-padded -Wno-c++98-compat-pedantic")
else()
message(STATUS "Using other compiler. (not clang)")
endif()
# Compiler flags based on build type
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
message(STATUS "Setting Debug Build Flags")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0")
else()
message(STATUS "Setting Release Build Flags")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -DNDEBUG")
endif()
# Subdirectory for the main artnet code
add_subdirectory(artnet)
# Example project
add_subdirectory(artnet/example)
# Custom target to build example, using out-of-source build
add_custom_target(build_artnet_example
COMMAND ${CMAKE_COMMAND} -S . -B build
COMMAND ${CMAKE_COMMAND} --build build
COMMENT "Building Art-Net Example"
)