Skip to content

Commit

Permalink
feat: add CMake option for C++ module consumption
Browse files Browse the repository at this point in the history
  • Loading branch information
netadr committed Feb 26, 2024
1 parent 97bcd14 commit 929a65e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ option(SAFETYHOOK_BUILD_TEST "" OFF)
option(SAFETYHOOK_BUILD_EXAMPLES "" OFF)
option(SAFETYHOOK_AMALGAMATE "" OFF)
option(SAFETYHOOK_FETCH_ZYDIS "" OFF)
option(SAFETYHOOK_USE_CXXMODULES "" OFF)

project(safetyhook)

Expand Down Expand Up @@ -146,6 +147,11 @@ target_link_libraries(safetyhook PUBLIC
Zydis
)

set(CMKR_TARGET safetyhook)
if(SAFETYHOOK_USE_CXXMODULES)
target_compile_definitions(safetyhook INTERFACE SAFETYHOOK_USE_CXXMODULES)
endif()

# Target: docs
if(SAFETYHOOK_BUILD_DOCS) # build-docs
set(CMKR_TARGET docs)
Expand Down
6 changes: 6 additions & 0 deletions cmake.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ SAFETYHOOK_BUILD_TEST = false
SAFETYHOOK_BUILD_EXAMPLES = false
SAFETYHOOK_AMALGAMATE = false
SAFETYHOOK_FETCH_ZYDIS = false
SAFETYHOOK_USE_CXXMODULES = false

[conditions]
build-docs = "SAFETYHOOK_BUILD_DOCS"
Expand Down Expand Up @@ -59,6 +60,11 @@ link-libraries = ["Zydis"]
msvc.private-compile-options = ["/permissive-", "/W4", "/w14640"]
clang.private-compile-options = ["-Wall", "-Wextra", "-Wshadow", "-Wnon-virtual-dtor", "-pedantic"]
gcc.private-compile-options = ["-Wall", "-Wextra", "-Wshadow", "-Wnon-virtual-dtor", "-pedantic"]
cmake-after = """
if(SAFETYHOOK_USE_CXXMODULES)
target_compile_definitions(safetyhook INTERFACE SAFETYHOOK_USE_CXXMODULES)
endif()
"""

[target.docs]
condition = "build-docs"
Expand Down

0 comments on commit 929a65e

Please sign in to comment.