-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
64 lines (54 loc) · 2.19 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
# CMakeLists.txt --- CMake project settings
# ex) cmake -G "Visual Studio 9 2008"
# ex) cmake -DCMAKE_BUILD_TYPE=Release -G "MSYS Makefiles"
##############################################################################
# CMake minimum version
cmake_minimum_required(VERSION 3.5)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0048 NEW)
endif(COMMAND cmake_policy)
# project name and language
project(Typaste CXX RC)
# check build type
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type selected, default to Debug")
set(CMAKE_BUILD_TYPE "Debug")
endif()
# make uppercase string of build type
string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
# check build type again
if (NOT uppercase_CMAKE_BUILD_TYPE MATCHES "^(DEBUG|RELEASE|RELWITHDEBINFO|MINSIZEREL)$")
message(FATAL_ERROR "Invalid value for CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# using Clang
set(CMAKE_C_FLAGS "-static -s")
set(CMAKE_CXX_FLAGS "-static -s")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# using GCC
set(CMAKE_C_FLAGS "-static -static-libgcc -static-libstdc++ -s")
set(CMAKE_CXX_FLAGS "-static -static-libgcc -static-libstdc++ -s")
elseif (MSVC)
# replace "/MD" with "/MT" (building without runtime DLLs)
set(CompilerFlags
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELWITHDEBINFO)
foreach(CompilerFlags ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlags} "${${CompilerFlags}}")
endforeach()
endif()
##############################################################################
# Typaste.exe
add_executable(Typaste WIN32 Typaste.cpp AutoType.cpp Typaste_res.rc)
target_compile_definitions(Typaste PRIVATE -DUNICODE -D_UNICODE) # Unicode support
target_link_libraries(Typaste comctl32 shell32 shlwapi winmm imm32)
if(MSVC)
target_link_options(Typaste PRIVATE /MANIFEST:NO)
endif()
##############################################################################