2021-08-25 13:20:31 +03:00
|
|
|
cmake_minimum_required(VERSION 3.16)
|
2020-09-05 07:30:09 +03:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
|
|
|
|
if(CMAKE_SIZEOF_VOID_P MATCHES 4)
|
|
|
|
set(BITNESS 32)
|
|
|
|
else()
|
|
|
|
set(BITNESS 64)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
include_directories(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
NCToolsShared
|
|
|
|
)
|
|
|
|
|
|
|
|
add_definitions(-DUNICODE)
|
|
|
|
add_definitions(-D_UNICODE)
|
|
|
|
add_definitions(-DNDEBUG)
|
|
|
|
add_definitions(-D_WINDOWS)
|
|
|
|
|
|
|
|
# Get APIs from from Vista onwards.
|
|
|
|
add_definitions(-D_WIN32_WINNT=0x0601)
|
|
|
|
add_definitions(-DWINVER=0x0601)
|
|
|
|
|
2020-09-09 22:01:38 +03:00
|
|
|
# Use automatic overload for suitable CRT safe-functions
|
|
|
|
# See https://docs.microsoft.com/de-de/cpp/c-runtime-library/security-features-in-the-crt?view=vs-2019
|
|
|
|
add_definitions(-D_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1)
|
|
|
|
# Also: Disable compiler warnings because we don't use Windows CRT safe-functions explicitly and don't intend to
|
|
|
|
# as this is a pure cross-platform source the only alternative would be a ton of ifdefs with calls to the _s version
|
|
|
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
2020-09-05 07:30:09 +03:00
|
|
|
|
2020-09-09 22:01:38 +03:00
|
|
|
# Optimize for size
|
|
|
|
set(COMPILER_FLAGS "/GL /O1 /sdl /Zc:inline /Oi /EHsc /nologo")
|
|
|
|
set(LINKER_FLAGS "/LTCG /OPT:REF /SUBSYSTEM:WINDOWS /NOLOGO")
|
2020-09-05 07:30:09 +03:00
|
|
|
|
2020-09-09 22:01:38 +03:00
|
|
|
# Enable DEP, ASLR and CFG
|
|
|
|
set(LINKER_FLAGS "${LINKER_FLAGS} /nxcompat /dynamicbase /guard:cf")
|
2020-09-05 07:30:09 +03:00
|
|
|
|
2020-09-09 22:01:38 +03:00
|
|
|
# x86 only: Enable SafeSEH
|
|
|
|
if(CMAKE_SIZEOF_VOID_P MATCHES 4)
|
|
|
|
set(LINKER_FLAGS "${LINKER_FLAGS} /safeseh")
|
|
|
|
endif()
|
2020-09-05 07:30:09 +03:00
|
|
|
|
2020-09-09 22:01:38 +03:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMPILER_FLAGS}")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILER_FLAGS}")
|
2020-09-05 07:30:09 +03:00
|
|
|
|
2020-09-09 22:01:38 +03:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LINKER_FLAGS}")
|
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${LINKER_FLAGS}")
|
2020-09-05 07:30:09 +03:00
|
|
|
|
2020-09-09 22:01:38 +03:00
|
|
|
# Use static runtime for all subdirectories
|
|
|
|
foreach(buildType "" "_DEBUG" "_MINSIZEREL" "_RELEASE" "_RELWITHDEBINFO")
|
|
|
|
string(REPLACE "/MD" "/MT" "CMAKE_CXX_FLAGS${buildType}" "${CMAKE_CXX_FLAGS${buildType}}")
|
|
|
|
endforeach()
|
2020-09-05 07:30:09 +03:00
|
|
|
|
|
|
|
add_subdirectory(NCToolsShared)
|
|
|
|
|
|
|
|
if(BUILD_WIN_MSI)
|
|
|
|
add_subdirectory(NCMsiHelper)
|
|
|
|
endif()
|
2020-09-05 07:58:48 +03:00
|
|
|
|
|
|
|
if(BUILD_WIN_TOOLS)
|
|
|
|
add_subdirectory(NCNavRemove)
|
|
|
|
endif()
|