-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
68 lines (59 loc) · 2.58 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
cmake_minimum_required(VERSION 3.1)
project(STMSIGBypass_cpp)
# Use the latest standard at this time.
set(CMAKE_CXX_STANDARD 17)
enable_language(ASM_MASM)
# Export to the a gitignored directory.
set(EXECUTABLE_OUTPUT_PATH ${STMSIGBypass_cpp_SOURCE_DIR}/Bin)
set(LIBRARY_OUTPUT_PATH ${STMSIGBypass_cpp_SOURCE_DIR}/Bin)
# Set warningflags per compiler.
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
if (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
endif()
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG} -g")
endif()
# Separate release and debugbuilds output and dependencies.
mark_as_advanced(CMAKE_IMPORT_LIBRARY_SUFFIX CMAKE_DEBUG_POSTFIX)
set(CMAKE_DEBUG_POSTFIX "d")
# Just pull all the files from /Source
file(GLOB_RECURSE SOURCES "Source/*.cpp")
file(GLOB_RECURSE ASSEMBLY "Source/*.asm")
# Build the requested version without the 'lib' prefix.
if(${CMAKE_SIZEOF_VOID_P} EQUAL 4)
add_library(STMSIGBypass SHARED ${SOURCES})
set_target_properties(STMSIGBypass PROPERTIES PREFIX "")
set_target_properties(STMSIGBypass PROPERTIES SUFFIX ".ayria32")
else()
add_library(STMSIGBypass SHARED ${SOURCES} ${ASSEMBLY})
set_target_properties(STMSIGBypass PROPERTIES PREFIX "")
set_target_properties(STMSIGBypass PROPERTIES SUFFIX ".ayria64")
endif()
# Differentiate between x64 and x86 builds.
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
if(${CMAKE_SIZEOF_VOID_P} EQUAL 4)
set_target_properties(STMSIGBypass PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32 -static-libgcc -static-libstdc++")
else()
set_target_properties(STMSIGBypass PROPERTIES COMPILE_FLAGS "-m64" LINK_FLAGS "-m64 -static-libgcc -static-libstdc++")
endif()
endif()
# Library dependencies for the platforms.
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
target_link_libraries(STMSIGBypass dl pthread)
else()
target_link_libraries(STMSIGBypass ws2_32)
endif()
# Use static VC runtimes when releasing on Windows.
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
foreach(flag_var
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
if(${flag_var} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif()
endforeach()
endif()