summaryrefslogtreecommitdiffstatshomepage
path: root/CMakeLists.txt
blob: 8814074cbe40321f43b18ec2ff0658c6f860ec19 (plain) (blame)
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
# oldstable as of May '26
# Plus, I'm pretty sure it's required for things like CONFIGURE_DEPENDS and
# CMAKE_MSVC_RUNTIME_LIBRARY and stuff.
cmake_minimum_required(VERSION 3.25)

project(winapi_debug CXX)
enable_testing()

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)

if (MSVC)
    add_compile_options(/MP /W4 /WX)
else()
    add_compile_options(-Wall -Wextra -pedantic -Werror)
endif()

add_compile_definitions(WIN32_LEAN_AND_MEAN NOMINMAX)

if(MSVC)
    # This is an ugly hack to make the tests work.
    # With incremental linking, the &func address does not point to the
    # function code, but to a jmp instruction to the real code (or it's the
    # other way around, I don't know).
    # This is apparently caused by incremental linking, e.g.
    # https://stackoverflow.com/questions/2485336/address-of-function-is-not-actual-code-address
    string(REPLACE "/INCREMENTAL" "/INCREMENTAL:NO"
        CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO
        "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}")
    string(REPLACE "/INCREMENTAL" "/INCREMENTAL:NO"
        CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO
        "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO}")
    string(REPLACE "/INCREMENTAL" "/INCREMENTAL:NO"
        CMAKE_EXE_LINKER_FLAGS_DEBUG
        "${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
    string(REPLACE "/INCREMENTAL" "/INCREMENTAL:NO"
        CMAKE_SHARED_LINKER_FLAGS_DEBUG
        "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
endif()

add_subdirectory(3rdparty/winapi/common EXCLUDE_FROM_ALL)

add_subdirectory(src)
add_subdirectory(test)

install(FILES LICENSE.txt DESTINATION share)