Skip to content

Commit b2d0fdf

Browse files
Merge pull request #192 from cjee21/cmake
CMake: More consistent flags with MSVC projects
2 parents d95706d + 64e2dff commit b2d0fdf

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

Project/CMake/CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,23 @@ set(BIN_INSTALL_DIR "${CMAKE_INSTALL_FULL_BINDIR}" CACHE STRING "Directory where
3939
set(LIB_INSTALL_DIR "${CMAKE_INSTALL_FULL_LIBDIR}" CACHE STRING "Directory where library will install")
4040
set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_FULL_INCLUDEDIR}" CACHE PATH "The directory the headers are installed in")
4141

42+
if(MSVC)
43+
add_compile_options(/GS /W3 /guard:cf /sdl)
44+
add_link_options(/guard:cf)
45+
if(CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL ARM64)
46+
add_compile_options(/guard:ehcont /guard:signret)
47+
add_link_options(/guard:ehcont /guard:delayloadsignret)
48+
endif()
49+
if(CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL x64)
50+
add_compile_options(/guard:ehcont)
51+
add_link_options(/guard:ehcont /CETCOMPAT)
52+
endif()
53+
if(CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL X86)
54+
add_compile_options()
55+
add_link_options(/CETCOMPAT)
56+
endif()
57+
endif()
58+
4259
if(VCPKG_TARGET_TRIPLET)
4360
set(ZenLib_CONFIG_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/zenlib")
4461
elseif(MSVC)

0 commit comments

Comments
 (0)