2011-05-16 13:12:07 +00:00
|
|
|
|
2021-04-15 01:52:59 +00:00
|
|
|
if(CMAKE_BUILD_TYPE STREQUAL "Release")
|
2020-09-21 10:16:02 +00:00
|
|
|
add_compile_options(/Ox /Ob2 /Ot /Oy /GT)
|
2011-05-16 13:12:07 +00:00
|
|
|
elseif(OPTIMIZE STREQUAL "1")
|
2020-09-21 10:16:02 +00:00
|
|
|
add_compile_options(/O1)
|
2011-05-16 13:12:07 +00:00
|
|
|
elseif(OPTIMIZE STREQUAL "2")
|
2020-09-21 10:16:02 +00:00
|
|
|
add_compile_options(/O2)
|
2011-05-16 13:12:07 +00:00
|
|
|
elseif(OPTIMIZE STREQUAL "3")
|
2020-09-21 10:16:02 +00:00
|
|
|
add_compile_options(/Ot /Ox /GS-)
|
2011-05-16 13:12:07 +00:00
|
|
|
elseif(OPTIMIZE STREQUAL "4")
|
2021-04-15 01:52:59 +00:00
|
|
|
add_compile_options(/Ob0 /Od)
|
2011-05-16 13:12:07 +00:00
|
|
|
elseif(OPTIMIZE STREQUAL "5")
|
2020-09-21 10:16:02 +00:00
|
|
|
add_compile_options(/Gy /Ob2 /Os /Ox /GS-)
|
2011-05-16 13:12:07 +00:00
|
|
|
endif()
|
|
|
|
|
2019-01-12 15:57:51 +00:00
|
|
|
# Always use string pooling: this helps reducing the binaries size since a lot
|
|
|
|
# of redundancy come from the usage of __FILE__ / __RELFILE__ in the debugging
|
|
|
|
# helper macros. Note also that GCC builds use string pooling by default.
|
2020-09-21 10:16:02 +00:00
|
|
|
add_compile_options(/GF)
|
2019-01-12 15:57:51 +00:00
|
|
|
|
2016-03-28 16:38:26 +00:00
|
|
|
# Enable function level linking and comdat folding
|
2020-09-21 10:16:02 +00:00
|
|
|
add_compile_options(/Gy)
|
|
|
|
add_link_options(/OPT:REF /OPT:ICF)
|
2016-03-28 16:38:26 +00:00
|
|
|
|
2012-08-27 18:58:27 +00:00
|
|
|
if(ARCH STREQUAL "i386")
|
2011-06-22 11:31:01 +00:00
|
|
|
add_definitions(/DWIN32 /D_WINDOWS)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_definitions(/Dinline=__inline /D__STDC__=1)
|
2011-05-16 13:12:07 +00:00
|
|
|
|
2019-01-12 15:57:51 +00:00
|
|
|
# Ignore any "standard" include paths, and do not use any default CRT library.
|
2017-10-27 21:18:01 +00:00
|
|
|
if(NOT USE_CLANG_CL)
|
2020-09-21 10:16:02 +00:00
|
|
|
add_compile_options(/X /Zl)
|
2017-10-27 21:18:01 +00:00
|
|
|
endif()
|
|
|
|
|
2020-09-21 10:16:02 +00:00
|
|
|
# Disable buffer security checks by default.
|
|
|
|
add_compile_options(/GS-)
|
2017-10-27 21:18:01 +00:00
|
|
|
|
|
|
|
if(USE_CLANG_CL)
|
|
|
|
set(CMAKE_CL_SHOWINCLUDES_PREFIX "Note: including file: ")
|
|
|
|
endif()
|
2011-06-22 13:17:37 +00:00
|
|
|
|
2012-07-08 19:59:33 +00:00
|
|
|
# HACK: for VS 11+ we need to explicitly disable SSE, which is off by
|
2013-09-11 19:25:48 +00:00
|
|
|
# default for older compilers. See CORE-6507
|
2020-04-25 00:14:44 +00:00
|
|
|
if(ARCH STREQUAL "i386")
|
2020-08-15 19:41:32 +00:00
|
|
|
# Clang's IA32 means i386, which doesn't have cmpxchg8b
|
|
|
|
if(USE_CLANG_CL)
|
2020-09-21 10:16:02 +00:00
|
|
|
add_compile_options(-march=${OARCH})
|
2020-08-15 19:41:32 +00:00
|
|
|
else()
|
2020-09-21 10:16:02 +00:00
|
|
|
add_compile_options(/arch:IA32)
|
2020-08-15 19:41:32 +00:00
|
|
|
endif()
|
2020-05-26 18:24:02 +00:00
|
|
|
endif()
|
2012-07-08 19:59:33 +00:00
|
|
|
|
2020-12-22 11:32:45 +00:00
|
|
|
# CLang default to -fno-common from version 11 onward. We are not rady for this now
|
|
|
|
if (USE_CLANG_CL)
|
|
|
|
add_compile_options(-fcommon)
|
|
|
|
endif()
|
|
|
|
|
2013-10-31 09:59:55 +00:00
|
|
|
# VS 12+ requires /FS when used in parallel compilations
|
2020-04-25 00:14:44 +00:00
|
|
|
if(NOT MSVC_IDE)
|
2020-09-21 10:16:02 +00:00
|
|
|
add_compile_options(/FS)
|
2020-05-26 18:24:02 +00:00
|
|
|
endif()
|
2013-10-31 09:59:55 +00:00
|
|
|
|
2015-04-30 21:48:26 +00:00
|
|
|
# VS14+ tries to use thread-safe initialization
|
2020-09-21 10:16:02 +00:00
|
|
|
add_compile_options(/Zc:threadSafeInit-)
|
2015-04-30 21:48:26 +00:00
|
|
|
|
2019-11-23 16:37:59 +00:00
|
|
|
# HACK: Disable use of __CxxFrameHandler4 on VS 16.3+ (x64 only)
|
|
|
|
# See https://developercommunity.visualstudio.com/content/problem/746534/visual-c-163-runtime-uses-an-unsupported-api-for-u.html
|
|
|
|
if(ARCH STREQUAL "amd64" AND MSVC_VERSION GREATER 1922)
|
2021-04-30 12:15:39 +00:00
|
|
|
if (NOT CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
|
|
|
add_compile_options(/d2FH4-)
|
|
|
|
endif()
|
2020-09-21 10:16:02 +00:00
|
|
|
add_link_options(/d2:-FH4-)
|
2020-05-26 18:24:02 +00:00
|
|
|
endif()
|
2019-11-23 16:37:59 +00:00
|
|
|
|
2019-01-12 15:57:51 +00:00
|
|
|
# Generate Warnings Level 3
|
2020-09-21 10:16:02 +00:00
|
|
|
add_compile_options(/W3)
|
2019-01-12 15:57:51 +00:00
|
|
|
|
2014-01-14 21:04:39 +00:00
|
|
|
# Disable overly sensitive warnings as well as those that generally aren't
|
|
|
|
# useful to us.
|
2014-08-31 10:55:32 +00:00
|
|
|
# - C4244: implicit integer truncation
|
2014-01-14 21:04:39 +00:00
|
|
|
# - C4290: C++ exception specification ignored
|
2015-02-14 15:44:44 +00:00
|
|
|
# - C4800: forcing value to bool 'true' or 'false' (performance warning)
|
2015-09-05 17:46:04 +00:00
|
|
|
# - C4200: nonstandard extension used : zero-sized array in struct/union
|
2015-09-11 20:18:12 +00:00
|
|
|
# - C4214: nonstandard extension used : bit field types other than int
|
2020-09-21 10:16:02 +00:00
|
|
|
add_compile_options(/wd4244 /wd4290 /wd4800 /wd4200 /wd4214)
|
2013-09-11 19:25:48 +00:00
|
|
|
|
2015-09-05 17:31:51 +00:00
|
|
|
# FIXME: Temporarily disable C4018 until we fix more of the others. CORE-10113
|
2020-09-21 10:16:02 +00:00
|
|
|
add_compile_options(/wd4018)
|
2015-09-05 17:31:51 +00:00
|
|
|
|
2013-09-14 13:18:51 +00:00
|
|
|
# The following warnings are treated as errors:
|
2014-01-14 21:04:39 +00:00
|
|
|
# - C4013: implicit function declaration
|
2014-02-28 23:34:32 +00:00
|
|
|
# - C4020: too many actual parameters
|
2013-11-05 20:52:36 +00:00
|
|
|
# - C4022: pointer type mismatch for parameter
|
2018-07-18 15:08:57 +00:00
|
|
|
# - C4028: formal parameter different from declaration
|
2013-09-14 13:18:51 +00:00
|
|
|
# - C4047: different level of indirection
|
2013-11-05 20:52:36 +00:00
|
|
|
# - TODO: C4090: different 'modifier' qualifiers (for C programs only;
|
2013-09-14 13:18:51 +00:00
|
|
|
# for C++ programs, the compiler error C2440 is issued)
|
|
|
|
# - C4098: void function returning a value
|
2020-02-24 09:48:24 +00:00
|
|
|
# - C4101: unreferenced local variable
|
2013-11-17 23:38:31 +00:00
|
|
|
# - C4113: parameter lists differ
|
2013-11-05 20:52:36 +00:00
|
|
|
# - C4129: unrecognized escape sequence
|
2018-02-27 21:00:40 +00:00
|
|
|
# - C4133: incompatible types - from '<x> *' to '<y> *'
|
2014-03-28 01:35:32 +00:00
|
|
|
# - C4163: 'identifier': not available as an intrinsic function
|
2013-11-17 19:45:32 +00:00
|
|
|
# - C4229: modifiers on data are ignored
|
2018-02-27 21:00:40 +00:00
|
|
|
# - C4311: pointer truncation from '<pointer>' to '<integer>'
|
|
|
|
# - C4312: conversion from '<integer>' to '<pointer>' of greater size
|
2019-07-20 15:34:24 +00:00
|
|
|
# - C4313: 'fprintf': '%x' in format string conflicts with argument n of type 'HANDLE'
|
|
|
|
# - C4477: '_snprintf' : format string '%ld' requires an argument of type 'long', but variadic argument 1 has type 'DWORD_PTR'
|
2014-02-12 19:55:12 +00:00
|
|
|
# - C4603: macro is not defined or definition is different after precompiled header use
|
2018-02-27 21:00:40 +00:00
|
|
|
# - C4700: uninitialized variable usage
|
2019-08-17 18:29:16 +00:00
|
|
|
# - C4715: 'function': not all control paths return a value
|
2015-03-10 00:09:58 +00:00
|
|
|
# - C4716: function must return a value
|
2020-09-18 09:49:18 +00:00
|
|
|
add_compile_options(/we4013 /we4020 /we4022 /we4028 /we4047 /we4098 /we4101 /we4113 /we4129 /we4133 /we4163 /we4229 /we4311 /we4312 /we4313 /we4477 /we4603 /we4700 /we4715 /we4716)
|
2015-05-28 12:19:24 +00:00
|
|
|
|
|
|
|
# - C4189: local variable initialized but not referenced
|
2021-04-15 01:52:59 +00:00
|
|
|
# Not in Release mode, msbuild generator doesn't like CMAKE_BUILD_TYPE
|
|
|
|
if(MSVC_IDE OR CMAKE_BUILD_TYPE STREQUAL "Debug")
|
2020-09-18 09:49:18 +00:00
|
|
|
add_compile_options(/we4189)
|
2015-05-28 12:19:24 +00:00
|
|
|
endif()
|
2012-02-23 13:06:11 +00:00
|
|
|
|
2013-11-18 00:04:15 +00:00
|
|
|
# Enable warnings above the default level, but don't treat them as errors:
|
|
|
|
# - C4115: named type definition in parentheses
|
2020-09-21 10:16:02 +00:00
|
|
|
add_compile_options(/w14115)
|
2013-11-18 00:04:15 +00:00
|
|
|
|
2017-10-27 21:18:01 +00:00
|
|
|
if(USE_CLANG_CL)
|
2020-09-18 14:18:24 +00:00
|
|
|
add_compile_options("$<$<COMPILE_LANGUAGE:C,CXX>:-nostdinc;-Wno-multichar;-Wno-char-subscripts;-Wno-microsoft-enum-forward-reference;-Wno-pragma-pack;-Wno-microsoft-anon-tag;-Wno-parentheses-equality;-Wno-unknown-pragmas>")
|
2017-10-27 21:18:01 +00:00
|
|
|
endif()
|
|
|
|
|
2012-01-14 17:27:17 +00:00
|
|
|
# Debugging
|
2021-04-15 01:52:59 +00:00
|
|
|
if(NOT (_PREFAST_ OR _VS_ANALYZE_))
|
|
|
|
add_compile_options($<$<CONFIG:Debug>:/Zi>)
|
2012-01-14 17:27:17 +00:00
|
|
|
endif()
|
2021-04-15 01:52:59 +00:00
|
|
|
add_compile_definitions($<$<CONFIG:Release>:NDEBUG>)
|
2012-01-14 17:27:17 +00:00
|
|
|
|
2015-11-04 18:06:16 +00:00
|
|
|
# Hotpatchable images
|
|
|
|
if(ARCH STREQUAL "i386")
|
2017-10-27 21:18:01 +00:00
|
|
|
if(NOT USE_CLANG_CL)
|
2020-09-18 09:49:18 +00:00
|
|
|
add_compile_options(/hotpatch)
|
2017-10-27 21:18:01 +00:00
|
|
|
endif()
|
2015-11-04 18:06:16 +00:00
|
|
|
set(_hotpatch_link_flag "/FUNCTIONPADMIN:5")
|
|
|
|
elseif(ARCH STREQUAL "amd64")
|
|
|
|
set(_hotpatch_link_flag "/FUNCTIONPADMIN:6")
|
|
|
|
endif()
|
|
|
|
|
2015-05-12 11:38:32 +00:00
|
|
|
if(MSVC_IDE AND (NOT DEFINED USE_FOLDER_STRUCTURE))
|
2015-11-27 21:46:54 +00:00
|
|
|
set(USE_FOLDER_STRUCTURE TRUE)
|
2011-05-16 13:12:07 +00:00
|
|
|
endif()
|
|
|
|
|
2014-10-12 22:59:32 +00:00
|
|
|
if(RUNTIME_CHECKS)
|
|
|
|
add_definitions(-D__RUNTIME_CHECKS__)
|
2020-09-21 10:16:02 +00:00
|
|
|
add_compile_options(/RTC1)
|
2014-10-12 22:59:32 +00:00
|
|
|
endif()
|
|
|
|
|
2020-09-21 10:16:02 +00:00
|
|
|
add_link_options(/MANIFEST:NO /INCREMENTAL:NO /SAFESEH:NO /NODEFAULTLIB /RELEASE ${_hotpatch_link_flag} /IGNORE:4039)
|
|
|
|
|
2020-06-06 22:20:09 +00:00
|
|
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "")
|
2011-06-11 16:09:57 +00:00
|
|
|
|
2018-08-19 20:01:31 +00:00
|
|
|
# HACK: Remove the /implib argument, implibs are generated separately
|
|
|
|
string(REPLACE "/implib:<TARGET_IMPLIB>" "" CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE}")
|
|
|
|
string(REPLACE "/implib:<TARGET_IMPLIB>" "" CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE}")
|
|
|
|
string(REPLACE "/implib:<TARGET_IMPLIB>" "" CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_C_CREATE_SHARED_LIBRARY}")
|
|
|
|
string(REPLACE "/implib:<TARGET_IMPLIB>" "" CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY}")
|
2019-03-20 13:19:48 +00:00
|
|
|
string(REPLACE "/implib:<TARGET_IMPLIB>" "" CMAKE_C_CREATE_SHARED_MODULE "${CMAKE_C_CREATE_SHARED_MODULE}")
|
|
|
|
string(REPLACE "/implib:<TARGET_IMPLIB>" "" CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE}")
|
2018-08-19 20:01:31 +00:00
|
|
|
|
2020-09-10 20:03:52 +00:00
|
|
|
# HACK2: CMake lacks the ability to completely remove the 'implib' argument for solution files...
|
|
|
|
# To work around this, we just let it create a dummy file
|
|
|
|
if(MSVC_IDE)
|
|
|
|
set(CMAKE_IMPORT_LIBRARY_SUFFIX ".dummy")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
2014-02-12 19:36:19 +00:00
|
|
|
if(CMAKE_DISABLE_NINJA_DEPSLOG)
|
|
|
|
set(cl_includes_flag "")
|
|
|
|
else()
|
|
|
|
set(cl_includes_flag "/showIncludes")
|
|
|
|
endif()
|
|
|
|
|
2020-06-06 20:59:26 +00:00
|
|
|
if(MSVC_IDE)
|
2014-03-24 20:54:01 +00:00
|
|
|
# For VS builds we'll only have en-US in resource files
|
2013-01-08 20:33:08 +00:00
|
|
|
add_definitions(/DLANGUAGE_EN_US)
|
2011-06-14 15:28:16 +00:00
|
|
|
else()
|
2020-08-15 19:40:31 +00:00
|
|
|
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> /nologo <INCLUDES> <FLAGS> <DEFINES> ${I18N_DEFS} /fo <OBJECT> <SOURCE>")
|
2021-01-21 09:20:21 +00:00
|
|
|
endif()
|
|
|
|
|
2021-01-22 10:28:11 +00:00
|
|
|
# We don't put <INCLUDES> <DEFINES> <FLAGS> because this is handled in add_asm_files macro
|
|
|
|
if (NOT MSVC_IDE)
|
|
|
|
if(ARCH STREQUAL "arm")
|
|
|
|
set(CMAKE_ASM_MASM_COMPILE_OBJECT "<CMAKE_ASM_MASM_COMPILER> -nologo -o <OBJECT> <SOURCE>")
|
|
|
|
else()
|
|
|
|
set(CMAKE_ASM_MASM_COMPILE_OBJECT "<CMAKE_ASM_MASM_COMPILER> /nologo /Cp /Fo <OBJECT> /c /Ta <SOURCE>")
|
|
|
|
endif()
|
2011-06-14 15:28:16 +00:00
|
|
|
endif()
|
2011-06-11 16:09:57 +00:00
|
|
|
|
2012-05-10 10:39:16 +00:00
|
|
|
if(_VS_ANALYZE_)
|
|
|
|
message("VS static analysis enabled!")
|
2020-09-21 10:16:02 +00:00
|
|
|
add_compile_options(/analyze)
|
2012-05-10 10:39:16 +00:00
|
|
|
elseif(_PREFAST_)
|
|
|
|
message("PREFAST enabled!")
|
2020-06-07 07:26:23 +00:00
|
|
|
set(CMAKE_C_COMPILE_OBJECT "prefast <CMAKE_C_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO} <INCLUDES> <FLAGS> <DEFINES> /Fo<OBJECT> -c <SOURCE>${CMAKE_END_TEMP_FILE}"
|
|
|
|
"prefast LIST")
|
|
|
|
set(CMAKE_CXX_COMPILE_OBJECT "prefast <CMAKE_CXX_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO} <INCLUDES> <FLAGS> <DEFINES> /TP /Fo<OBJECT> -c <SOURCE>${CMAKE_END_TEMP_FILE}"
|
|
|
|
"prefast LIST")
|
|
|
|
set(CMAKE_C_LINK_EXECUTABLE
|
|
|
|
"<CMAKE_C_COMPILER> ${CMAKE_CL_NOLOGO} <OBJECTS> ${CMAKE_START_TEMP_FILE} <INCLUDES> <FLAGS> /Fe<TARGET> -link /implib:<TARGET_IMPLIB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>${CMAKE_END_TEMP_FILE}")
|
|
|
|
set(CMAKE_CXX_LINK_EXECUTABLE
|
|
|
|
"<CMAKE_CXX_COMPILER> ${CMAKE_CL_NOLOGO} <OBJECTS> ${CMAKE_START_TEMP_FILE} <INCLUDES> <FLAGS> /Fe<TARGET> -link /implib:<TARGET_IMPLIB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>${CMAKE_END_TEMP_FILE}")
|
2012-01-05 17:19:15 +00:00
|
|
|
endif()
|
|
|
|
|
2011-05-16 13:12:07 +00:00
|
|
|
set(CMAKE_RC_CREATE_SHARED_LIBRARY ${CMAKE_C_CREATE_SHARED_LIBRARY})
|
2021-01-21 09:20:21 +00:00
|
|
|
set(CMAKE_ASM_MASM_CREATE_SHARED_LIBRARY ${CMAKE_C_CREATE_SHARED_LIBRARY})
|
2019-03-20 13:19:48 +00:00
|
|
|
set(CMAKE_RC_CREATE_SHARED_MODULE ${CMAKE_C_CREATE_SHARED_MODULE})
|
2021-01-21 09:20:21 +00:00
|
|
|
set(CMAKE_ASM_MASM_CREATE_SHARED_MODULE ${CMAKE_C_CREATE_SHARED_MODULE})
|
2011-06-11 16:09:57 +00:00
|
|
|
set(CMAKE_ASM_CREATE_STATIC_LIBRARY ${CMAKE_C_CREATE_STATIC_LIBRARY})
|
2011-05-16 13:12:07 +00:00
|
|
|
|
2011-08-20 12:29:51 +00:00
|
|
|
function(set_entrypoint _module _entrypoint)
|
|
|
|
if(${_entrypoint} STREQUAL "0")
|
2011-09-03 14:57:27 +00:00
|
|
|
add_target_link_flags(${_module} "/NOENTRY")
|
2012-08-27 18:58:27 +00:00
|
|
|
elseif(ARCH STREQUAL "i386")
|
2011-08-20 12:29:51 +00:00
|
|
|
set(_entrysymbol ${_entrypoint})
|
2011-10-02 18:59:33 +00:00
|
|
|
if(${ARGC} GREATER 2)
|
2011-08-20 12:29:51 +00:00
|
|
|
set(_entrysymbol ${_entrysymbol}@${ARGV2})
|
|
|
|
endif()
|
2011-09-03 14:57:27 +00:00
|
|
|
add_target_link_flags(${_module} "/ENTRY:${_entrysymbol}")
|
2011-05-16 13:12:07 +00:00
|
|
|
else()
|
2011-09-03 14:57:27 +00:00
|
|
|
add_target_link_flags(${_module} "/ENTRY:${_entrypoint}")
|
2011-05-16 13:12:07 +00:00
|
|
|
endif()
|
2011-08-08 11:54:20 +00:00
|
|
|
endfunction()
|
2011-05-16 13:12:07 +00:00
|
|
|
|
2011-08-08 11:54:20 +00:00
|
|
|
function(set_subsystem MODULE SUBSYSTEM)
|
2015-05-12 12:18:02 +00:00
|
|
|
string(TOUPPER ${SUBSYSTEM} _subsystem)
|
2014-01-22 22:46:30 +00:00
|
|
|
if(ARCH STREQUAL "amd64")
|
2015-05-12 12:18:02 +00:00
|
|
|
add_target_link_flags(${MODULE} "/SUBSYSTEM:${_subsystem},5.02")
|
2015-05-13 12:12:20 +00:00
|
|
|
elseif(ARCH STREQUAL "arm")
|
|
|
|
add_target_link_flags(${MODULE} "/SUBSYSTEM:${_subsystem},6.02")
|
2013-08-28 12:32:09 +00:00
|
|
|
else()
|
2015-05-12 12:18:02 +00:00
|
|
|
add_target_link_flags(${MODULE} "/SUBSYSTEM:${_subsystem},5.01")
|
2013-08-28 12:32:09 +00:00
|
|
|
endif()
|
2011-08-08 11:54:20 +00:00
|
|
|
endfunction()
|
2011-05-16 13:12:07 +00:00
|
|
|
|
2011-08-08 11:54:20 +00:00
|
|
|
function(set_image_base MODULE IMAGE_BASE)
|
2011-09-03 14:57:27 +00:00
|
|
|
add_target_link_flags(${MODULE} "/BASE:${IMAGE_BASE}")
|
2011-08-08 11:54:20 +00:00
|
|
|
endfunction()
|
2011-05-16 13:12:07 +00:00
|
|
|
|
2011-09-03 17:48:57 +00:00
|
|
|
function(set_module_type_toolchain MODULE TYPE)
|
2021-03-23 08:54:46 +00:00
|
|
|
# Set the PE image version numbers from the NT OS version ReactOS is based on
|
|
|
|
target_link_options(${MODULE} PRIVATE "/VERSION:5.01")
|
|
|
|
|
2021-02-24 10:46:53 +00:00
|
|
|
if((TYPE STREQUAL win32dll) OR (TYPE STREQUAL win32ocx) OR (TYPE STREQUAL cpl))
|
|
|
|
target_link_options(${MODULE} PRIVATE /DLL)
|
|
|
|
elseif(TYPE IN_LIST KERNEL_MODULE_TYPES)
|
|
|
|
# Mark INIT section as Executable Read Write Discardable
|
|
|
|
target_link_options(${MODULE} PRIVATE /SECTION:INIT,ERWD)
|
|
|
|
|
|
|
|
if(TYPE STREQUAL kernelmodedriver)
|
|
|
|
target_link_options(${MODULE} PRIVATE /DRIVER)
|
|
|
|
elseif(TYPE STREQUAL wdmdriver)
|
|
|
|
target_link_options(${MODULE} PRIVATE /DRIVER:WDM)
|
|
|
|
elseif (TYPE STREQUAL kernel)
|
|
|
|
# Mark .rsrc section as non-disposable non-pageable, as bugcheck code needs to access it
|
2021-03-23 08:54:46 +00:00
|
|
|
target_link_options(${MODULE} PRIVATE /SECTION:.rsrc,!DP)
|
2021-02-24 10:46:53 +00:00
|
|
|
endif()
|
2011-05-16 13:12:07 +00:00
|
|
|
endif()
|
2014-10-18 14:22:09 +00:00
|
|
|
|
|
|
|
if(RUNTIME_CHECKS)
|
|
|
|
target_link_libraries(${MODULE} runtmchk)
|
|
|
|
endif()
|
|
|
|
|
2011-08-08 11:54:20 +00:00
|
|
|
endfunction()
|
2011-05-16 13:12:07 +00:00
|
|
|
|
2013-07-14 11:44:21 +00:00
|
|
|
function(add_delay_importlibs _module)
|
|
|
|
get_target_property(_module_type ${_module} TYPE)
|
|
|
|
if(_module_type STREQUAL "STATIC_LIBRARY")
|
|
|
|
message(FATAL_ERROR "Cannot add delay imports to a static library")
|
|
|
|
endif()
|
2013-07-14 21:00:42 +00:00
|
|
|
foreach(_lib ${ARGN})
|
2017-12-31 12:08:39 +00:00
|
|
|
get_filename_component(_basename "${_lib}" NAME_WE)
|
|
|
|
get_filename_component(_ext "${_lib}" EXT)
|
|
|
|
if(NOT _ext)
|
|
|
|
set(_ext ".dll")
|
|
|
|
endif()
|
|
|
|
add_target_link_flags(${_module} "/DELAYLOAD:${_basename}${_ext}")
|
|
|
|
target_link_libraries(${_module} "lib${_basename}")
|
2011-08-11 13:39:06 +00:00
|
|
|
endforeach()
|
2013-07-14 11:44:21 +00:00
|
|
|
target_link_libraries(${_module} delayimp)
|
|
|
|
endfunction()
|
2011-06-10 20:44:47 +00:00
|
|
|
|
2020-04-13 10:20:47 +00:00
|
|
|
function(fixup_load_config _target)
|
|
|
|
# msvc knows how to generate a load_config so no hacks here
|
|
|
|
endfunction()
|
|
|
|
|
2012-04-29 19:04:02 +00:00
|
|
|
function(generate_import_lib _libname _dllname _spec_file)
|
2012-08-06 20:29:38 +00:00
|
|
|
|
2020-10-22 14:25:46 +00:00
|
|
|
set(_def_file ${CMAKE_CURRENT_BINARY_DIR}/${_libname}_implib.def)
|
2012-08-06 20:29:38 +00:00
|
|
|
set(_asm_stubs_file ${CMAKE_CURRENT_BINARY_DIR}/${_libname}_stubs.asm)
|
2013-09-22 21:04:06 +00:00
|
|
|
|
2020-11-02 09:51:08 +00:00
|
|
|
# Generate the def and asm stub files
|
2012-04-29 19:04:02 +00:00
|
|
|
add_custom_command(
|
2012-08-06 20:29:38 +00:00
|
|
|
OUTPUT ${_asm_stubs_file} ${_def_file}
|
2013-11-17 22:11:04 +00:00
|
|
|
COMMAND native-spec2def --ms -a=${SPEC2DEF_ARCH} --implib -n=${_dllname} -d=${_def_file} -l=${_asm_stubs_file} ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file}
|
2012-04-29 19:04:02 +00:00
|
|
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file} native-spec2def)
|
2013-09-22 21:04:06 +00:00
|
|
|
|
2020-11-02 09:51:08 +00:00
|
|
|
# Compile the generated asm stub file
|
|
|
|
if(ARCH STREQUAL "arm")
|
2021-01-21 09:20:21 +00:00
|
|
|
set(_asm_stub_command ${CMAKE_ASM_MASM_COMPILER} -nologo -o ${_asm_stubs_file}.obj ${_asm_stubs_file})
|
2012-08-06 20:29:38 +00:00
|
|
|
else()
|
2021-01-21 09:20:21 +00:00
|
|
|
set(_asm_stub_command ${CMAKE_ASM_MASM_COMPILER} /nologo /Cp /Fo${_asm_stubs_file}.obj /c /Ta ${_asm_stubs_file})
|
2012-08-06 20:29:38 +00:00
|
|
|
endif()
|
2020-11-02 09:51:08 +00:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${_asm_stubs_file}.obj
|
|
|
|
COMMAND ${_asm_stub_command}
|
|
|
|
DEPENDS ${_asm_stubs_file})
|
2012-04-29 19:04:02 +00:00
|
|
|
|
2020-11-02 09:51:08 +00:00
|
|
|
# generate the intermediate import lib
|
|
|
|
set(_libfile_tmp ${CMAKE_CURRENT_BINARY_DIR}/${_libname}_tmp.lib)
|
|
|
|
set(_static_lib_options )
|
|
|
|
|
2021-01-03 01:06:51 +00:00
|
|
|
set(_implib_command ${CMAKE_LINKER} /LIB /NOLOGO /MACHINE:${WINARCH}
|
|
|
|
$<TARGET_PROPERTY:${_libname},STATIC_LIBRARY_FLAGS> $<TARGET_PROPERTY:${_libname},STATIC_LIBRARY_OPTIONS>
|
|
|
|
/DEF:${_def_file} /OUT:${_libfile_tmp} ${_asm_stubs_file}.obj)
|
|
|
|
|
2020-11-02 09:51:08 +00:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${_libfile_tmp}
|
2021-01-03 01:06:51 +00:00
|
|
|
COMMAND ${_implib_command}
|
2020-11-02 09:51:08 +00:00
|
|
|
DEPENDS ${_asm_stubs_file}.obj ${_def_file})
|
|
|
|
|
|
|
|
# By giving the import lib as an object input, LIB extracts the relevant object files and make a new library.
|
|
|
|
# This allows us to treat the implib as a regular static library
|
|
|
|
set_source_files_properties(${_libfile_tmp} PROPERTIES EXTERNAL_OBJECT TRUE)
|
|
|
|
add_library(${_libname} STATIC ${_libfile_tmp})
|
|
|
|
|
|
|
|
set_target_properties(${_libname} PROPERTIES LINKER_LANGUAGE "C")
|
2012-04-29 19:04:02 +00:00
|
|
|
endfunction()
|
|
|
|
|
2012-08-27 18:58:27 +00:00
|
|
|
if(ARCH STREQUAL "amd64")
|
2014-05-27 21:32:42 +00:00
|
|
|
# This is NOT a typo.
|
|
|
|
# See https://software.intel.com/en-us/forums/topic/404643
|
|
|
|
add_definitions(/D__x86_64)
|
2012-03-07 21:21:27 +00:00
|
|
|
set(SPEC2DEF_ARCH x86_64)
|
2014-05-26 15:28:12 +00:00
|
|
|
elseif(ARCH STREQUAL "arm")
|
|
|
|
add_definitions(/D__arm__)
|
|
|
|
set(SPEC2DEF_ARCH arm)
|
2012-03-07 21:21:27 +00:00
|
|
|
else()
|
|
|
|
set(SPEC2DEF_ARCH i386)
|
|
|
|
endif()
|
2011-08-08 11:54:20 +00:00
|
|
|
function(spec2def _dllname _spec_file)
|
2015-02-07 23:54:15 +00:00
|
|
|
|
2018-09-05 19:59:16 +00:00
|
|
|
cmake_parse_arguments(__spec2def "ADD_IMPORTLIB;NO_PRIVATE_WARNINGS;WITH_RELAY" "VERSION" "" ${ARGN})
|
2012-04-20 12:39:00 +00:00
|
|
|
|
2014-03-24 20:54:01 +00:00
|
|
|
# Get library basename
|
2012-03-07 21:21:27 +00:00
|
|
|
get_filename_component(_file ${_dllname} NAME_WE)
|
2012-04-20 12:39:00 +00:00
|
|
|
|
2014-03-24 20:54:01 +00:00
|
|
|
# Error out on anything else than spec
|
2012-03-07 21:21:27 +00:00
|
|
|
if(NOT ${_spec_file} MATCHES ".*\\.spec")
|
|
|
|
message(FATAL_ERROR "spec2def only takes spec files as input.")
|
2011-08-15 15:36:25 +00:00
|
|
|
endif()
|
2012-04-20 12:39:00 +00:00
|
|
|
|
2020-05-26 18:24:02 +00:00
|
|
|
if(__spec2def_WITH_RELAY)
|
2018-09-05 19:51:59 +00:00
|
|
|
set(__with_relay_arg "--with-tracing")
|
|
|
|
endif()
|
|
|
|
|
2018-09-05 19:59:16 +00:00
|
|
|
if(__spec2def_VERSION)
|
|
|
|
set(__version_arg "--version=0x${__spec2def_VERSION}")
|
|
|
|
endif()
|
|
|
|
|
2014-03-24 20:54:01 +00:00
|
|
|
# Generate exports def and C stubs file for the DLL
|
2011-05-16 13:12:07 +00:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file}.def ${CMAKE_CURRENT_BINARY_DIR}/${_file}_stubs.c
|
2018-09-05 19:59:16 +00:00
|
|
|
COMMAND native-spec2def --ms -a=${SPEC2DEF_ARCH} -n=${_dllname} -d=${CMAKE_CURRENT_BINARY_DIR}/${_file}.def -s=${CMAKE_CURRENT_BINARY_DIR}/${_file}_stubs.c ${__with_relay_arg} ${__version_arg} ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file}
|
2011-08-05 20:40:40 +00:00
|
|
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file} native-spec2def)
|
2012-03-31 21:52:09 +00:00
|
|
|
|
2015-02-07 23:54:15 +00:00
|
|
|
if(__spec2def_ADD_IMPORTLIB)
|
2012-04-29 19:04:02 +00:00
|
|
|
generate_import_lib(lib${_file} ${_dllname} ${_spec_file})
|
2015-09-13 06:22:58 +00:00
|
|
|
if(__spec2def_NO_PRIVATE_WARNINGS)
|
2020-11-02 09:51:08 +00:00
|
|
|
set_property(TARGET lib${_file} APPEND PROPERTY STATIC_LIBRARY_OPTIONS /ignore:4104)
|
2015-09-13 06:22:58 +00:00
|
|
|
endif()
|
2012-03-07 21:21:27 +00:00
|
|
|
endif()
|
2011-08-08 11:54:20 +00:00
|
|
|
endfunction()
|
2011-05-16 13:12:07 +00:00
|
|
|
|
2011-10-03 19:09:26 +00:00
|
|
|
macro(macro_mc FLAG FILE)
|
2016-09-28 23:20:20 +00:00
|
|
|
set(COMMAND_MC ${CMAKE_MC_COMPILER} -u ${FLAG} -b -h ${CMAKE_CURRENT_BINARY_DIR}/ -r ${CMAKE_CURRENT_BINARY_DIR}/ ${FILE})
|
2011-05-16 13:12:07 +00:00
|
|
|
endmacro()
|
|
|
|
|
2014-03-24 20:54:01 +00:00
|
|
|
# PSEH workaround
|
2011-05-16 13:12:07 +00:00
|
|
|
set(PSEH_LIB "pseh")
|
2011-06-07 23:22:38 +00:00
|
|
|
|
2012-08-24 15:36:17 +00:00
|
|
|
# Use a full path for the x86 version of ml when using x64 VS.
|
|
|
|
# It's not a problem when using the DDK/WDK because, in x64 mode,
|
|
|
|
# both the x86 and x64 versions of ml are available.
|
2017-10-19 08:18:19 +00:00
|
|
|
if((ARCH STREQUAL "amd64") AND (DEFINED ENV{VCToolsInstallDir}))
|
|
|
|
set(CMAKE_ASM16_COMPILER $ENV{VCToolsInstallDir}/bin/HostX86/x86/ml.exe)
|
|
|
|
elseif((ARCH STREQUAL "amd64") AND (DEFINED ENV{VCINSTALLDIR}))
|
2011-08-26 17:33:33 +00:00
|
|
|
set(CMAKE_ASM16_COMPILER $ENV{VCINSTALLDIR}/bin/ml.exe)
|
2014-05-26 15:28:12 +00:00
|
|
|
elseif(ARCH STREQUAL "arm")
|
|
|
|
set(CMAKE_ASM16_COMPILER armasm.exe)
|
2011-08-26 17:33:33 +00:00
|
|
|
else()
|
|
|
|
set(CMAKE_ASM16_COMPILER ml.exe)
|
|
|
|
endif()
|
|
|
|
|
2012-04-20 12:39:00 +00:00
|
|
|
function(CreateBootSectorTarget _target_name _asm_file _binary_file _base_address)
|
2011-06-07 23:22:38 +00:00
|
|
|
set(_object_file ${_binary_file}.obj)
|
|
|
|
set(_temp_file ${_binary_file}.tmp)
|
|
|
|
|
2020-03-06 21:55:12 +00:00
|
|
|
get_defines(_defines)
|
|
|
|
get_includes(_includes)
|
|
|
|
|
2017-12-07 22:22:27 +00:00
|
|
|
if(USE_CLANG_CL)
|
|
|
|
set(_no_std_includes_flag "-nostdinc")
|
|
|
|
else()
|
|
|
|
set(_no_std_includes_flag "/X")
|
|
|
|
endif()
|
|
|
|
|
2011-06-07 23:22:38 +00:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${_temp_file}
|
2020-03-06 21:55:12 +00:00
|
|
|
COMMAND ${CMAKE_C_COMPILER} /nologo ${_no_std_includes_flag} /I${REACTOS_SOURCE_DIR}/sdk/include/asm /I${REACTOS_BINARY_DIR}/sdk/include/asm ${_includes} ${_defines} /D__ASM__ /D_USE_ML /EP /c ${_asm_file} > ${_temp_file}
|
2011-06-07 23:22:38 +00:00
|
|
|
DEPENDS ${_asm_file})
|
|
|
|
|
2014-05-26 15:28:12 +00:00
|
|
|
if(ARCH STREQUAL "arm")
|
|
|
|
set(_asm16_command ${CMAKE_ASM16_COMPILER} -nologo -o ${_object_file} ${_temp_file})
|
|
|
|
else()
|
|
|
|
set(_asm16_command ${CMAKE_ASM16_COMPILER} /nologo /Cp /Fo${_object_file} /c /Ta ${_temp_file})
|
|
|
|
endif()
|
|
|
|
|
2011-06-07 23:22:38 +00:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${_object_file}
|
2014-05-26 15:28:12 +00:00
|
|
|
COMMAND ${_asm16_command}
|
2011-06-07 23:22:38 +00:00
|
|
|
DEPENDS ${_temp_file})
|
|
|
|
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${_binary_file}
|
|
|
|
COMMAND native-obj2bin ${_object_file} ${_binary_file} ${_base_address}
|
2011-08-05 20:40:40 +00:00
|
|
|
DEPENDS ${_object_file} native-obj2bin)
|
2011-06-07 23:22:38 +00:00
|
|
|
|
|
|
|
set_source_files_properties(${_object_file} ${_temp_file} ${_binary_file} PROPERTIES GENERATED TRUE)
|
|
|
|
|
|
|
|
add_custom_target(${_target_name} ALL DEPENDS ${_binary_file})
|
2011-08-08 11:54:20 +00:00
|
|
|
endfunction()
|
2011-09-11 00:44:13 +00:00
|
|
|
|
|
|
|
function(allow_warnings __module)
|
|
|
|
endfunction()
|
2013-01-08 20:33:08 +00:00
|
|
|
|
|
|
|
macro(add_asm_files _target)
|
2021-01-22 10:28:11 +00:00
|
|
|
get_defines(_directory_defines)
|
|
|
|
get_includes(_directory_includes)
|
|
|
|
get_directory_property(_defines COMPILE_DEFINITIONS)
|
|
|
|
foreach(_source_file ${ARGN})
|
|
|
|
get_filename_component(_source_file_base_name ${_source_file} NAME_WE)
|
|
|
|
get_filename_component(_source_file_full_path ${_source_file} ABSOLUTE)
|
|
|
|
set(_preprocessed_asm_file ${CMAKE_CURRENT_BINARY_DIR}/asm/${_source_file_base_name}_${_target}.asm)
|
|
|
|
get_source_file_property(_defines_semicolon_list ${_source_file_full_path} COMPILE_DEFINITIONS)
|
|
|
|
unset(_source_file_defines)
|
|
|
|
foreach(_define ${_defines_semicolon_list})
|
|
|
|
if(NOT ${_define} STREQUAL "NOTFOUND")
|
|
|
|
list(APPEND _source_file_defines -D${_define})
|
2014-05-26 15:28:12 +00:00
|
|
|
endif()
|
2013-01-08 20:33:08 +00:00
|
|
|
endforeach()
|
2021-01-22 10:28:11 +00:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${_preprocessed_asm_file}
|
|
|
|
COMMAND cl /nologo /X /I${REACTOS_SOURCE_DIR}/sdk/include/asm /I${REACTOS_BINARY_DIR}/sdk/include/asm ${_directory_includes} ${_source_file_defines} ${_directory_defines} /D__ASM__ /D_USE_ML /EP /c ${_source_file_full_path} > ${_preprocessed_asm_file}
|
|
|
|
DEPENDS ${_source_file_full_path})
|
|
|
|
list(APPEND ${_target} ${_preprocessed_asm_file})
|
|
|
|
endforeach()
|
2013-01-08 20:33:08 +00:00
|
|
|
endmacro()
|
2019-02-09 23:43:31 +00:00
|
|
|
|
|
|
|
function(add_linker_script _target _linker_script_file)
|
|
|
|
get_filename_component(_file_full_path ${_linker_script_file} ABSOLUTE)
|
|
|
|
get_filename_component(_file_name ${_linker_script_file} NAME)
|
|
|
|
set(_generated_file_path_prefix "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_target}.dir/${_file_name}")
|
|
|
|
|
|
|
|
# Generate the ASM module containing sections specifications and layout.
|
|
|
|
set(_generated_file "${_generated_file_path_prefix}.S")
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${_generated_file}
|
|
|
|
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${_file_full_path}" "${_generated_file}"
|
|
|
|
DEPENDS ${_file_full_path})
|
2021-01-21 09:20:21 +00:00
|
|
|
set_source_files_properties(${_generated_file} PROPERTIES LANGUAGE "ASM_MASM" GENERATED TRUE)
|
2019-02-09 23:43:31 +00:00
|
|
|
add_asm_files(${_target}_linker_file ${_generated_file})
|
|
|
|
|
|
|
|
# Generate the C module containing extra sections specifications and layout,
|
|
|
|
# as well as comment-type linker #pragma directives.
|
|
|
|
set(_generated_file "${_generated_file_path_prefix}.c")
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${_generated_file}
|
|
|
|
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${_file_full_path}" "${_generated_file}"
|
|
|
|
DEPENDS ${_file_full_path})
|
|
|
|
set_source_files_properties(${_generated_file} PROPERTIES LANGUAGE "C" GENERATED TRUE)
|
|
|
|
list(APPEND ${_target}_linker_file ${_generated_file})
|
|
|
|
|
|
|
|
# Add both files to the sources of the target.
|
|
|
|
target_sources(${_target} PRIVATE "${${_target}_linker_file}")
|
|
|
|
|
|
|
|
# Create the additional linker response file.
|
|
|
|
set(_generated_file "${_generated_file_path_prefix}.rsp")
|
|
|
|
if(USE_CLANG_CL)
|
|
|
|
set(_no_std_includes_flag "-nostdinc")
|
|
|
|
else()
|
|
|
|
set(_no_std_includes_flag "/X")
|
|
|
|
endif()
|
2020-06-06 20:59:26 +00:00
|
|
|
if(MSVC_IDE)
|
2019-02-09 23:47:43 +00:00
|
|
|
# MSBuild, via the VS IDE, uses response files when calling CL or LINK.
|
|
|
|
# We cannot specify a custom response file on the linker command-line,
|
|
|
|
# since specifying response files from within response files is forbidden.
|
|
|
|
# We therefore have to pre-process, at configuration time, the linker
|
|
|
|
# script so as to retrieve the custom linker options to be appended
|
|
|
|
# to the linker command-line.
|
|
|
|
execute_process(
|
|
|
|
COMMAND ${CMAKE_C_COMPILER} /nologo ${_no_std_includes_flag} /D__LINKER__ /EP /c "${_file_full_path}"
|
|
|
|
# OUTPUT_FILE "${_generated_file}"
|
|
|
|
OUTPUT_VARIABLE linker_options
|
|
|
|
ERROR_QUIET
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
RESULT_VARIABLE linker_rsp_result
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
if(NOT linker_rsp_result EQUAL 0)
|
|
|
|
message(FATAL_ERROR "Generating pre-processed linker options for target '${_target}' failed with error ${linker_rsp_result}.")
|
|
|
|
endif()
|
|
|
|
# file(STRINGS ${_generated_file} linker_options NEWLINE_CONSUME)
|
|
|
|
string(REGEX REPLACE "[\r\n]+" " " linker_options "${linker_options}")
|
|
|
|
add_target_link_flags(${_target} ${linker_options})
|
|
|
|
else()
|
|
|
|
# Generate at compile-time a linker response file and append it
|
|
|
|
# to the linker command-line.
|
|
|
|
add_custom_command(
|
|
|
|
# OUTPUT ${_generated_file}
|
|
|
|
TARGET ${_target} PRE_LINK # PRE_BUILD
|
|
|
|
COMMAND ${CMAKE_C_COMPILER} /nologo ${_no_std_includes_flag} /D__LINKER__ /EP /c "${_file_full_path}" > "${_generated_file}"
|
|
|
|
DEPENDS ${_file_full_path}
|
|
|
|
VERBATIM)
|
|
|
|
set_source_files_properties(${_generated_file} PROPERTIES GENERATED TRUE)
|
|
|
|
# add_custom_target("${_target}_${_file_name}" ALL DEPENDS ${_generated_file})
|
|
|
|
# add_dependencies(${_target} "${_target}_${_file_name}")
|
|
|
|
add_target_link_flags(${_target} "@${_generated_file}")
|
2019-04-27 09:26:03 +00:00
|
|
|
add_target_property(${_target} LINK_DEPENDS ${_file_full_path})
|
2019-02-09 23:47:43 +00:00
|
|
|
endif()
|
2019-02-09 23:43:31 +00:00
|
|
|
endfunction()
|
2020-09-18 07:34:18 +00:00
|
|
|
|
|
|
|
# handle C++ options
|
|
|
|
# disable RTTI unless said so
|
|
|
|
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:$<IF:$<BOOL:$<TARGET_PROPERTY:WITH_CXX_RTTI>>,/GR,/GR->>")
|
|
|
|
# disable exceptions unless said so
|
|
|
|
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:$<IF:$<BOOL:$<TARGET_PROPERTY:WITH_CXX_EXCEPTIONS>>,/EHsc,/EHs-c->>")
|
|
|
|
|
|
|
|
# Create our interface libraries wrapping the needed library for this compiler
|
|
|
|
add_library(cppstl INTERFACE)
|
|
|
|
target_link_libraries(cppstl INTERFACE cpprt stlport oldnames)
|
|
|
|
# We set this properties through our INTERFACE library
|
|
|
|
set_target_properties(cppstl PROPERTIES INTERFACE_WITH_CXX_STL TRUE)
|
|
|
|
# add_library(cpprt INTERFACE)
|
|
|
|
# Our runtime library is already called cpprt
|