-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
80 lines (64 loc) · 2.18 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
# TODO: https://pabloariasal.github.io/2018/02/19/its-time-to-do-cmake-right/
cmake_minimum_required(VERSION 3.11)
set(project "Dn-FamiTracker")
set(exe "Dn-FamiTracker")
include(cmake_user_begin.cmake OPTIONAL)
project(${project})
# MFC based off https://github.com/Kitware/CMake/blob/master/Tests/MFC/CMakeLists.txt
# also sets https://stackoverflow.com/questions/14172856/cmake-mt-md
# Simpler approach (unimplemented): https://stackoverflow.com/questions/11580748/cmake-mfc
# does not set mt vs md
# Configure MFC
if (CMAKE_BUILD_TYPE MATCHES DEBUG)
# Debug build requires dynamic MFC.
set(STATIC_MSVCRT 0)
else ()
# Otherwise link MFC statically.
set(STATIC_MSVCRT 1)
endif ()
include(cmake/mfc.cmake)
# compiling
include(cmake/exe.cmake)
#builds the .chm file
if(WIN32)
add_custom_command(TARGET ${exe}
PRE_BUILD
COMMAND cmd /c ${CMAKE_CURRENT_SOURCE_DIR}/cmake/compile-chm.bat
COMMAND move Dn-Famitracker.chm ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Generating help file...")
endif()
target_compile_features(${exe} PRIVATE cxx_std_17)
if(COMMAND target_precompile_headers)
target_precompile_headers(${exe} PRIVATE
"$<$<COMPILE_LANGUAGE:CXX>:Source/stdafx.cpp>"
)
endif()
# linking
TARGET_LINK_LIBRARIES(${exe}
Dbghelp winmm comctl32 dsound Version htmlhelp)
# Dn-FamiTracker.rc includes res/Dn-FamiTracker.manifest.
# To prevent manifest linking errors:
# - res/Dn-FamiTracker.manifest MUST not be in add_executable().
# - /MANIFEST:NO must be passed into the linker.
set_property(
TARGET ${exe}
APPEND_STRING PROPERTY LINK_FLAGS
" /MANIFEST:NO"
)
# Generating .pdb files
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC" AND CMAKE_BUILD_TYPE MATCHES "Release")
target_compile_options(${exe} PRIVATE /Zi)
# Tell linker to include symbol data
set_property(
TARGET ${exe}
APPEND_STRING PROPERTY LINK_FLAGS
" /INCREMENTAL:NO /DEBUG /OPT:REF /OPT:ICF"
)
# Set file name & location
set_target_properties(${exe} PROPERTIES
COMPILE_PDB_NAME ${exe}
COMPILE_PDB_OUTPUT_DIR ${CMAKE_BINARY_DIR}
)
endif()
include(cmake_user_end.cmake OPTIONAL)