-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
81 lines (70 loc) · 2.39 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
cmake_minimum_required(VERSION 3.28)
project(Ipponboard-Main VERSION 2.2.0 LANGUAGES CXX)
# Define variables for the required MSVC runtime libraries
if(MSVC)
include(InstallRequiredSystemLibraries)
if(NOT DEFINED MSVC_REDIST_DIR)
message(FATAL_ERROR "MSVC_REDIST_DIR not defined. See InstallRequiredSystemLibraries.cmake in Visual Studio installation.")
endif()
endif()
# Read variables from config
file(STRINGS "env_cfg.bat" CONFIG_OUTPUT)
# Process each line to extract variables
string(REPLACE "\n" ";" CONFIG_LINES "${CONFIG_OUTPUT}")
foreach(line ${CONFIG_LINES})
string(REGEX MATCH "^set \"([^=]+)=(.*)\"" _ ${line})
if (CMAKE_MATCH_1 AND CMAKE_MATCH_2)
set(CFG_${CMAKE_MATCH_1} ${CMAKE_MATCH_2})
#message(${CMAKE_MATCH_1}=${CMAKE_MATCH_2})
endif()
endforeach()
# Check if QTDIR is configured
if(MSVC)
if(NOT DEFINED CFG_QTDIR)
message(FATAL_ERROR "QTDIR not configured in env_cfg.bat")
endif()
set(QTDIR ${CFG_QTDIR})
else()
set(USE_QT5 ON)
if(NOT DEFINED CFG_LINUX_QTDIR)
message(FATAL_ERROR "LINUX_QTDIR not configured in env_cfg.bat")
endif()
set(QTDIR ${CFG_LINUX_QTDIR})
endif()
message(STATUS "Using: QTDIR = ${QTDIR}")
set(CMAKE_PREFIX_PATH ${QTDIR})
set(CMAKE_LIBRARY_PATH ${QTDIR}/lib)
# Check if BOOST_DIR is configured
if(MSVC)
if(NOT DEFINED CFG_BOOST_DIR)
message(FATAL_ERROR "BOOST_DIR not configured in env_cfg.bat")
endif()
set(BOOST_DIR ${CFG_BOOST_DIR})
else()
if(NOT DEFINED BOOST_DIR)
set(BOOST_DIR ${CFG_LINUX_BOOST_DIR})
endif()
endif()
message(STATUS "Using: BOOST_DIR = ${BOOST_DIR}")
# Check if INNO_DIR is configured
if(WIN32)
if(NOT DEFINED CFG_INNO_DIR)
message(FATAL_ERROR "INNO_DIR not configured in env_cfg.bat")
endif()
set(INNO_DIR ${CFG_INNO_DIR})
message(STATUS "Using: INNO_DIR = ${INNO_DIR}")
endif()
set(ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
message(STATUS "Using: ROOT_DIR = ${ROOT_DIR}")
# Restrict multi configurations to Release and Debug
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE)
# Configure c++ language support
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Add targets
add_subdirectory(test ${CMAKE_BINARY_DIR}/build-Test)
add_subdirectory(base ${CMAKE_BINARY_DIR}/build-Ipponboard)
if(MSVC)
add_subdirectory(GamepadDemo ${CMAKE_BINARY_DIR}/build-GamepadDemo)
endif()