-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathCMakeLists.txt
61 lines (51 loc) · 2.23 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
cmake_minimum_required (VERSION 3.15)
cmake_policy(SET CMP0091 NEW)
project(fuckncsi C CXX)
option(SHIM_FORCE_ASM_ENTRY "Force using assembly defined entry")
set(SHIM_FORCE_ASM_LANGUAGE "" CACHE STRING "")
if(DEFINED MSVC_CXX_ARCHITECTURE_ID)
message(STATUS "Using MSVC /MT")
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
add_subdirectory(detours)
add_library(fuckncsi OBJECT fuckncsi.cpp)
target_compile_features(fuckncsi PRIVATE cxx_std_17)
target_link_libraries(fuckncsi detours)
add_library(shim_c shim.c shim_declare.h shim.def)
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(_SHIM_USE_ASM_ENTRY "${SHIM_FORCE_ASM_ENTRY}")
set(_SHIM_ASM_LANG ASM_NASM)
elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
if(MSVC_CXX_ARCHITECTURE_ID STREQUAL "X86")
set(_SHIM_USE_ASM_ENTRY "${SHIM_FORCE_ASM_ENTRY}")
set(_SHIM_ASM_LANG ASM_MASM)
elseif(MSVC_CXX_ARCHITECTURE_ID STREQUAL "AMD64" OR MSVC_CXX_ARCHITECTURE_ID STREQUAL "x64")
set(_SHIM_USE_ASM_ENTRY ON)
set(_SHIM_ASM_LANG ASM_MASM)
else()
message(FATAL_ERROR "no shim implementation for MSVC targeting ${MSVC_CXX_ARCHITECTURE_ID}")
endif()
endif()
if(_SHIM_USE_ASM_ENTRY)
if(NOT SHIM_FORCE_ASM_LANGUAGE STREQUAL "")
set(_SHIM_ASM_LANG "${SHIM_FORCE_ASM_LANGUAGE}")
endif()
message(STATUS "Using assembly entry in ${_SHIM_ASM_LANG}")
enable_language("${_SHIM_ASM_LANG}")
if(_SHIM_ASM_LANG STREQUAL "ASM_MASM")
set(SHIM_ASM_SOURCES shim_masm.asm)
elseif(_SHIM_ASM_LANG STREQUAL "ASM_NASM")
set(SHIM_ASM_SOURCES shim_nasm.asm)
else()
message(FATAL_ERROR "no shim implementation available")
endif()
set(SHIM_ASM_SOURCES "${SHIM_ASM_SOURCES}" shim_declare.inc)
add_library(shim_asm OBJECT "${SHIM_ASM_SOURCES}")
if(_SHIM_ASM_LANG STREQUAL "ASM_NASM")
target_include_directories(shim_asm PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
endif()
target_compile_definitions(shim_c PRIVATE SHIM_USE_EXTERNAL_ENTRY)
target_link_libraries(shim_c shim_asm)
endif()
add_library(nlasvc2 SHARED shim.def)
target_link_libraries(nlasvc2 fuckncsi shim_c)