-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
90 lines (69 loc) · 2.12 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
82
83
84
85
86
87
88
89
90
cmake_minimum_required(VERSION 3.20)
project(NEPS2)
# Enforce MSVC
if (NOT MSVC)
message(FATAL_ERROR "Sowwey :c Only MSVC is supported currently ;w;")
endif()
###########################################################################################
# Required packages
find_package(Vulkan REQUIRED)
# Find source files recursively
set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
file(GLOB SOURCE_FILES
${SOURCE_DIR}/*.cxx
${SOURCE_DIR}/*.cpp
${SOURCE_DIR}/*.c
)
file(GLOB_RECURSE SOURCE_FILES2
${SOURCE_DIR}/include/*.cxx
${SOURCE_DIR}/include/*.cpp
${SOURCE_DIR}/include/*.c
${SOURCE_DIR}/cs2/*.cxx
${SOURCE_DIR}/neps/*.cxx
)
list(APPEND SOURCE_FILES ${SOURCE_FILES2})
# Create target
add_library(NEPS2_DLL SHARED ${SOURCE_FILES})
# Set the precompiled header file
target_precompile_headers(NEPS2_DLL PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:${SOURCE_DIR}/pch.hpp>
$<$<COMPILE_LANGUAGE:C>:stddef.h>
)
# Add used include directories to include search paths
target_include_directories(NEPS2_DLL PRIVATE ${SOURCE_DIR})
target_include_directories(NEPS2_DLL PRIVATE ${SOURCE_DIR}/include)
# Add include dirs after find_package beautifully fails to
target_include_directories(NEPS2_DLL PRIVATE ${Vulkan_INCLUDE_DIRS})
# Pre-processor macro definitions
target_compile_definitions(NEPS2_DLL PRIVATE
$<$<CONFIG:Debug>:_DEBUG>
$<$<CONFIG:Release>:NDEBUG>
NOMINMAX
)
# Set compiler options
if(MSVC)
target_compile_options(NEPS2_DLL PRIVATE
$<$<CONFIG:Debug>:/Od /Zi>
$<$<CONFIG:Release>:/2d /Qpar>
/Gv
)
endif()
# Set the C++ standard
target_compile_features(NEPS2_DLL PRIVATE cxx_std_23)
# Link static libraries
if(MSVC)
target_link_libraries(NEPS2_DLL d3d11.lib)
# find_package apparently fails to do this
target_link_libraries(NEPS2_DLL ${Vulkan_LIBRARIES})
endif()
# Set the output filename
set_target_properties(NEPS2_DLL PROPERTIES
OUTPUT_NAME "NEPS2"
SUFFIX ".dll"
)
###########################################################################################
# Tests
find_package(Python)
enable_testing()
set(TESTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tests)
add_test(NAME Sanity COMMAND ${Python_EXECUTABLE} ${TESTS_DIR}/sanity.py)