[CMAKE] Get rid of the set_cpp macro
authorJérôme Gardou <jerome.gardou@reactos.org>
Fri, 18 Sep 2020 07:34:18 +0000 (09:34 +0200)
committerJérôme Gardou <zefklop@users.noreply.github.com>
Tue, 20 Oct 2020 19:44:54 +0000 (21:44 +0200)
Instead of messing with global variables and the like, we introduce two target properties:
 - WITH_CXX_EXCEPTIONS: if you want to use C++ exceptions
 - WITH_CXX_RTTI: if you need RTTI in your module
You can use the newly introduced set_target_cpp_properties function, with WITH_EXCEPTIONS and WITH_RTTI arguments
We also introduce two libraries :
 - cpprt: for C++ runtime routines
 - cppstl: for the C++ standard template library

NB: On GCC, this requires to create imported libraries with the related built-in libraries:libsupc++, limingwex, libstdc++

Finally, we manage the relevant flags with the ad-hoc generator expressions

So, if you don't need exceptions, nor RTTI, nor use any runtime at all: you simply have nothing else to do than add your C++ file to your module

69 files changed:
CMakeLists.txt
base/applications/atactl/CMakeLists.txt
base/applications/charmap_new/CMakeLists.txt
base/applications/drwtsn32/CMakeLists.txt
base/applications/fltmc/CMakeLists.txt
base/applications/games/solitaire/CMakeLists.txt
base/applications/games/spider/CMakeLists.txt
base/applications/msconfig_new/CMakeLists.txt
base/applications/mspaint/CMakeLists.txt
base/applications/network/telnet/CMakeLists.txt
base/applications/rapps/CMakeLists.txt
base/applications/sndrec32/CMakeLists.txt
base/shell/explorer/CMakeLists.txt
base/shell/rshell/CMakeLists.txt
dll/directx/ksproxy/CMakeLists.txt
dll/opengl/glu32/CMakeLists.txt
dll/shellext/acppage/CMakeLists.txt
dll/shellext/fontext/CMakeLists.txt
dll/shellext/mydocs/CMakeLists.txt
dll/shellext/netshell/CMakeLists.txt
dll/shellext/ntobjshex/CMakeLists.txt
dll/shellext/sendmail/CMakeLists.txt
dll/shellext/shellbtrfs/CMakeLists.txt
dll/shellext/stobject/CMakeLists.txt
dll/shellext/zipfldr/CMakeLists.txt
dll/win32/browseui/CMakeLists.txt
dll/win32/browseui/shellbars/CMakeLists.txt
dll/win32/browseui/shellfind/CMakeLists.txt
dll/win32/devmgr/CMakeLists.txt
dll/win32/framedyn/CMakeLists.txt
dll/win32/msgina/CMakeLists.txt
dll/win32/shell32/CMakeLists.txt
dll/win32/shell32/shelldesktop/CMakeLists.txt
dll/win32/shell32/shellmenu/CMakeLists.txt
dll/win32/shlwapi/CMakeLists.txt
drivers/filesystems/udfs/CMakeLists.txt
drivers/storage/ide/uniata/CMakeLists.txt
drivers/usb/usbaudio/CMakeLists.txt
drivers/wdm/audio/backpln/portcls/CMakeLists.txt
drivers/wdm/audio/drivers/CMIDriver/CMakeLists.txt
drivers/wdm/audio/drivers/CMIDriver/cmicontrol/CMakeLists.txt
drivers/wdm/audio/drivers/CMIDriver/cpl/CMakeLists.txt
drivers/wdm/audio/hdaudbus/CMakeLists.txt
modules/rosapps/applications/devutils/gdb2/CMakeLists.txt
modules/rosapps/applications/devutils/shlextdbg/CMakeLists.txt
modules/rosapps/applications/explorer-old/CMakeLists.txt
modules/rosapps/applications/fraginator/CMakeLists.txt
modules/rosapps/applications/net/netreg/CMakeLists.txt
modules/rosapps/applications/net/roshttpd/CMakeLists.txt
modules/rosapps/applications/sysutils/fontsub/CMakeLists.txt
modules/rosapps/applications/sysutils/regexpl/CMakeLists.txt
modules/rosapps/lib/vfdlib/CMakeLists.txt
modules/rostests/apitests/apphelp/CMakeLists.txt
modules/rostests/apitests/atl/CMakeLists.txt
modules/rostests/apitests/browseui/CMakeLists.txt
modules/rostests/apitests/fontext/CMakeLists.txt
modules/rostests/apitests/msgina/CMakeLists.txt
modules/rostests/apitests/ole32/CMakeLists.txt
modules/rostests/apitests/shell32/CMakeLists.txt
modules/rostests/apitests/zipfldr/CMakeLists.txt
modules/rostests/rosautotest/CMakeLists.txt
sdk/cmake/CMakeMacros.cmake
sdk/cmake/gcc.cmake
sdk/cmake/msvc.cmake
sdk/lib/3rdparty/cardlib/CMakeLists.txt
sdk/lib/3rdparty/stlport/CMakeLists.txt
sdk/lib/comsupp/CMakeLists.txt
sdk/lib/cpprt/CMakeLists.txt
sdk/lib/drivers/sound/stdunk/CMakeLists.txt

index ce1995e..cefcc5f 100644 (file)
@@ -111,6 +111,20 @@ else()
     set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
     set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
 
+    # Add our own target properties
+    # C++
+    define_property(TARGET PROPERTY WITH_CXX_EXCEPTIONS
+        BRIEF_DOCS "Enable C++ exceptions on this target"
+        FULL_DOCS [[
+Enables C++ exception handling.
+Enable this if the module uses try/catch or throw. You might also need this if you use a standard operator new (the one without nothrow).]])
+    define_property(TARGET PROPERTY WITH_CXX_RTTI
+        BRIEF_DOCS "Enable C++ RTTI on this target"
+        FULL_DOCS [[
+Enables run-time type information.
+Enable this if the module uses typeid or dynamic_cast. You will probably need to link yith cpprt as well, if you are not already using STL.]])
+
+
     if(DBG)
         add_definitions(-DDBG=1 -D_SEH_ENABLE_TRACE)
     else()
index 0070358..e75dbbd 100644 (file)
@@ -1,5 +1,4 @@
 
-set_cpp()
 add_definitions(-DUSER_MODE)
 include_directories(${REACTOS_SOURCE_DIR}/drivers/storage/ide/uniata)
 add_executable(atactl atactl.cpp atactl.rc)
index 3863bca..0e26047 100644 (file)
@@ -1,14 +1,12 @@
 PROJECT(CHARMAP)
 
-set_cpp(WITH_RTTI WITH_RUNTIME WITH_EXCEPTIONS)
-
 if(NOT MSVC)
     # HACK: this should be enabled globally!
     add_compile_flags_language("-std=c++11" "CXX")
 endif()
 
 include_directories(
-    ${REACTOS_SOURCE_DIR}/sdk/lib/atl 
+    ${REACTOS_SOURCE_DIR}/sdk/lib/atl
     includes)
 
 list(APPEND SOURCE
@@ -21,7 +19,8 @@ add_library(charmap MODULE
     charmap.rc)
 
 set_module_type(charmap win32gui UNICODE)
-target_link_libraries(charmap uuid wine)
+target_link_libraries(charmap uuid wine cpprt)
+set_target_cpp_properties(charmap WITH_EXCEPTIONS WITH_RTTI)
 add_importlibs(charmap advapi32 user32 gdi32 comctl32 version msvcrt kernel32 ole32 uxtheme ntdll)
 add_pch(charmap precomp.h SOURCE)
 add_cd_file(TARGET charmap DESTINATION reactos/system32 FOR all)
index fbc210b..55d5f6c 100644 (file)
@@ -1,7 +1,6 @@
 
 PROJECT(drwtsn32)
 
-set_cpp(WITH_RUNTIME WITH_EXCEPTIONS WITH_STL)
 include_directories(
     ${REACTOS_SOURCE_DIR}/sdk/lib/atl
     ${REACTOS_SOURCE_DIR}/sdk/lib/udmihelp)
@@ -17,6 +16,7 @@ list(APPEND CPP_SOURCE
 add_executable(drwtsn32 ${CPP_SOURCE} drwtsn32.rc)
 add_pch(drwtsn32 precomp.h CPP_SOURCE)
 set_module_type(drwtsn32 win32gui UNICODE)
-target_link_libraries(drwtsn32 udmihelp)
+target_link_libraries(drwtsn32 udmihelp cppstl)
+set_target_cpp_properties(drwtsn32 WITH_EXCEPTIONS)
 add_importlibs(drwtsn32 dbghelp psapi advapi32 shell32 shlwapi msvcrt user32 kernel32 ntdll)
 add_cd_file(TARGET drwtsn32 DESTINATION reactos/system32 FOR all)
index 01bf7a3..3e0aa70 100644 (file)
@@ -2,11 +2,11 @@
 remove_definitions(-D_WIN32_WINNT=0x502 -DWINVER=0x502)
 add_definitions(-D_WIN32_WINNT=0x601)
 
-set_cpp(WITH_RUNTIME WITH_EXCEPTIONS)
-
 include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/atl)
 
 add_executable(fltmc fltmc.cpp fltmc.rc)
+target_link_libraries(fltmc cpprt)
+set_target_cpp_properties(fltmc WITH_EXCEPTIONS)
 set_module_type(fltmc win32cui UNICODE)
 add_importlibs(fltmc fltlib msvcrt kernel32 advapi32)
 add_cd_file(TARGET fltmc DESTINATION reactos/system32 FOR all)
index 9cb6723..a0f0837 100644 (file)
@@ -1,7 +1,4 @@
 
-set_cpp(WITH_RUNTIME)
-include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/3rdparty/cardlib)
-
 list(APPEND SOURCE
     solcreate.cpp
     solgame.cpp
index 5948076..78d4f64 100644 (file)
@@ -1,10 +1,4 @@
 
-set_cpp(WITH_RUNTIME)
-
-include_directories(
-    ${REACTOS_SOURCE_DIR}/sdk/lib/3rdparty/cardlib
-    ${CMAKE_CURRENT_SOURCE_DIR})
-
 list(APPEND SOURCE
     spider.cpp
     spigame.cpp
@@ -13,6 +7,7 @@ list(APPEND SOURCE
 add_rc_deps(rsrc.rc ${CMAKE_CURRENT_SOURCE_DIR}/spider.ico)
 add_executable(spider ${SOURCE} rsrc.rc)
 target_link_libraries(spider cardlib)
+target_include_directories(spider PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
 add_pch(spider spider.h SOURCE)
 set_module_type(spider win32gui UNICODE)
 add_importlibs(spider advapi32 comctl32 user32 gdi32 msvcrt kernel32)
index 0fc32ec..5d8ebbe 100644 (file)
@@ -1,8 +1,6 @@
 
 PROJECT(msconfig_new)
 
-set_cpp(WITH_RUNTIME WITH_EXCEPTIONS)
-
 include_directories(
     .
     comctl32ex
@@ -35,6 +33,7 @@ add_rc_deps(msconfig.rc ${CMAKE_CURRENT_SOURCE_DIR}/res/msconfig.ico)
 add_executable(msconfig_new ${C_SOURCE} ${CPP_SOURCE} msconfig.rc)
 add_pch(msconfig_new precomp.h CPP_SOURCE)
 set_module_type(msconfig_new win32gui UNICODE)
-target_link_libraries(msconfig_new comsupp)
+target_link_libraries(msconfig_new comsupp cpprt)
+set_target_cpp_properties(msconfig_new WITH_EXCEPTIONS)
 add_importlibs(msconfig_new user32 gdi32 comctl32 comdlg32 advapi32 version ole32 oleaut32 msxml3 shell32 shlwapi msvcrt kernel32)
 add_cd_file(TARGET msconfig_new DESTINATION reactos/system32 FOR all)
index b07e10d..c5ba106 100644 (file)
@@ -1,7 +1,6 @@
 project(MSPAINT)
 
 add_definitions(-DINITGUID)
-set_cpp(WITH_RUNTIME WITH_EXCEPTIONS)
 
 include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/atl)
 
@@ -33,7 +32,8 @@ file(GLOB mspaint_rc_deps icons/*.*)
 add_rc_deps(rsrc.rc ${mspaint_rc_deps})
 add_executable(mspaint ${SOURCE} rsrc.rc)
 set_module_type(mspaint win32gui UNICODE)
-target_link_libraries(mspaint uuid)
+target_link_libraries(mspaint uuid cpprt)
+set_target_cpp_properties(mspaint WITH_EXCEPTIONS)
 add_importlibs(mspaint hhctrl comdlg32 shell32 user32 gdi32 advapi32 comctl32 msvcrt kernel32 rpcrt4 shlwapi)
 add_pch(mspaint precomp.h SOURCE)
 add_cd_file(TARGET mspaint DESTINATION reactos/system32 FOR all)
index 8e586fa..acd2aa0 100644 (file)
@@ -1,6 +1,4 @@
 
-set_cpp(WITH_EXCEPTIONS WITH_STL)
-
 add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
 
 if(NOT MSVC)
@@ -34,6 +32,8 @@ if(NOT MSVC)
 endif()
 
 add_executable(telnet ${SOURCE} telnet.rc)
+target_link_libraries(telnet cppstl)
+set_target_cpp_properties(telnet WITH_EXCEPTIONS)
 set_module_type(telnet win32cui)
 add_importlibs(telnet ws2_32 user32 msvcrt kernel32 ntdll)
 add_pch(telnet precomp.h SOURCE)
index 62a61d2..0616ddd 100644 (file)
@@ -1,7 +1,5 @@
 project(rapps)
 
-set_cpp(WITH_RUNTIME)
-
 include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/atl)
 include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/cryptlib)
 include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils)
@@ -46,7 +44,7 @@ file(GLOB_RECURSE rapps_rc_deps res/*.*)
 add_rc_deps(rapps.rc ${rapps_rc_deps})
 add_executable(rapps ${SOURCE} rapps.rc)
 set_module_type(rapps win32cui UNICODE)
-target_link_libraries(rapps conutils ${PSEH_LIB} uuid wine)
+target_link_libraries(rapps conutils ${PSEH_LIB} uuid wine cpprt)
 add_importlibs(rapps advapi32 comctl32 gdi32 wininet user32 shell32 shlwapi ole32 setupapi gdiplus msvcrt kernel32 ntdll)
 add_pch(rapps include/rapps.h SOURCE)
 add_dependencies(rapps rappsmsg)
index 83809d2..3a97846 100644 (file)
@@ -1,6 +1,4 @@
 
-set_cpp(WITH_RUNTIME)
-
 list(APPEND SOURCE
     audio_format.cpp
     audio_membuffer.cpp
@@ -15,6 +13,7 @@ list(APPEND SOURCE
 file(GLOB sndrec32_rc_deps resources/*.*)
 add_rc_deps(rsrc.rc ${sndrec32_rc_deps})
 add_executable(sndrec32 ${SOURCE} rsrc.rc)
+target_link_libraries(sndrec32 cpprt)
 set_module_type(sndrec32 win32gui UNICODE)
 add_importlibs(sndrec32 winmm user32 msacm32 comctl32 comdlg32 gdi32 shell32 msvcrt kernel32)
 add_pch(sndrec32 stdafx.h SOURCE)
index 1856249..33d9044 100644 (file)
@@ -1,6 +1,5 @@
 PROJECT(SHELL)
 
-set_cpp(WITH_RUNTIME)
 add_definitions(-D_ATL_NO_EXCEPTIONS)
 include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/atl)
 
@@ -31,7 +30,7 @@ list(APPEND SOURCE
 file(GLOB explorer_rc_deps res/*.*)
 add_rc_deps(explorer.rc ${explorer_rc_deps})
 add_executable(explorer ${SOURCE} explorer.rc)
-target_link_libraries(explorer uuid wine)
+target_link_libraries(explorer uuid wine cpprt)
 set_module_type(explorer win32gui UNICODE)
 add_importlibs(explorer advapi32 gdi32 user32 comctl32 ole32 oleaut32 shell32 browseui shlwapi shdocvw version uxtheme msvcrt kernel32 ntdll)
 add_pch(explorer precomp.h SOURCE)
index a272217..c47a121 100644 (file)
@@ -3,8 +3,6 @@ PROJECT(SHELL)
 add_definitions(
     -D_ATL_NO_EXCEPTIONS)
 
-set_cpp(WITH_RUNTIME)
-
 include_directories(
     ${REACTOS_SOURCE_DIR}/sdk/lib/atl)
 
@@ -24,7 +22,8 @@ target_link_libraries(rshell
     shellmenu
     shelldesktop
     uuid
-    wine)
+    wine
+    cpprt)
 
 add_importlibs(rshell
     browseui
@@ -40,14 +39,14 @@ add_importlibs(rshell
     kernel32
     ntdll)
 
-add_custom_command(TARGET rshell POST_BUILD 
-  COMMAND "${CMAKE_COMMAND}" -E copy 
+add_custom_command(TARGET rshell POST_BUILD
+  COMMAND "${CMAKE_COMMAND}" -E copy
      "$<TARGET_FILE:rshell>"
-     "$<TARGET_FILE_DIR:explorer>/$<TARGET_FILE_NAME:rshell>" 
+     "$<TARGET_FILE_DIR:explorer>/$<TARGET_FILE_NAME:rshell>"
   COMMENT "Copying to output directory")
 
-add_custom_command(TARGET rshell POST_BUILD 
-  COMMAND "${CMAKE_COMMAND}" -E copy 
+add_custom_command(TARGET rshell POST_BUILD
+  COMMAND "${CMAKE_COMMAND}" -E copy
      "$<TARGET_FILE:rshell>"
-     "$<TARGET_FILE_DIR:filebrowser>/$<TARGET_FILE_NAME:rshell>" 
+     "$<TARGET_FILE_DIR:filebrowser>/$<TARGET_FILE_NAME:rshell>"
   COMMENT "Copying to output directory")
index 15d7ebc..b6d070d 100644 (file)
@@ -1,5 +1,4 @@
 
-set_cpp(WITH_STL)
 spec2def(ksproxy.ax ksproxy.spec)
 
 list(APPEND SOURCE
@@ -25,7 +24,7 @@ list(APPEND SOURCE
 add_library(ksproxy MODULE ${SOURCE} ksproxy.rc)
 set_module_type(ksproxy win32dll)
 set_target_properties(ksproxy PROPERTIES SUFFIX ".ax")
-target_link_libraries(ksproxy strmiids)
+target_link_libraries(ksproxy strmiids cppstl)
 add_importlibs(ksproxy advapi32 ole32 setupapi ksuser msvcrt kernel32 ntdll)
 add_dependencies(ksproxy dxsdk)
 add_cd_file(TARGET ksproxy DESTINATION reactos/system32 FOR all)
index b2e6de9..490732e 100644 (file)
@@ -1,6 +1,4 @@
 
-set_cpp(WITH_RUNTIME)
-
 include_directories(BEFORE
     include
     src/include
@@ -118,6 +116,7 @@ add_library(glu32 MODULE
     ${PCH_SKIP_SOURCE}
     glu32.rc
     ${CMAKE_CURRENT_BINARY_DIR}/glu32.def)
+target_link_libraries(glu32 cpprt)
 
 set_module_type(glu32 win32dll)
 
index f4dc6e1..a8708a5 100644 (file)
@@ -1,7 +1,6 @@
 
 project(appcompat)
 
-set_cpp(WITH_RUNTIME)
 if(NOT MSVC)
     # HACK: this should be enabled globally!
     add_compile_flags_language("-std=c++11" "CXX")
@@ -32,7 +31,7 @@ add_library(acppage MODULE
     ${CMAKE_CURRENT_BINARY_DIR}/acppage.def)
 
 set_module_type(acppage win32dll UNICODE)
-target_link_libraries(acppage wine uuid)
+target_link_libraries(acppage wine uuid cpprt)
 add_delay_importlibs(acppage apphelp ole32 oleaut32 shlwapi comctl32 sfc_os)
 add_importlibs(acppage shell32 user32 advapi32 msvcrt kernel32)
 add_pch(acppage precomp.h SOURCE)
index e50eebf..5ceac56 100644 (file)
@@ -5,7 +5,6 @@ add_definitions(
 remove_definitions(-D_WIN32_WINNT=0x502 -DWINVER=0x502)
 add_definitions(-D_WIN32_WINNT=0x601 -DWINVER=0x601)
 
-set_cpp(WITH_RUNTIME)
 
 spec2def(fontext.dll fontext.spec)
 
@@ -32,7 +31,7 @@ add_library(fontext MODULE
     ${CMAKE_CURRENT_BINARY_DIR}/fontext.def)
 
 set_module_type(fontext win32dll UNICODE)
-target_link_libraries(fontext uuid wine)
+target_link_libraries(fontext uuid wine cpprt)
 add_delay_importlibs(fontext ole32 oleaut32 shlwapi gdi32)
 add_importlibs(fontext shell32 advapi32 user32 msvcrt kernel32 ntdll)
 add_pch(fontext precomp.h SOURCE)
index 0c9649c..4abbd64 100644 (file)
@@ -1,4 +1,3 @@
-set_cpp(WITH_RUNTIME)
 spec2def(mydocs.dll mydocs.spec)
 
 add_definitions(
@@ -28,7 +27,7 @@ add_library(mydocs MODULE
     ${CMAKE_CURRENT_BINARY_DIR}/mydocs.def)
 
 set_module_type(mydocs win32dll UNICODE)
-target_link_libraries(mydocs uuid wine)
+target_link_libraries(mydocs uuid wine cpprt)
 add_delay_importlibs(mydocs ole32 oleaut32)
 add_importlibs(mydocs advapi32 shell32 user32 comctl32 shlwapi msvcrt kernel32 ntdll)
 add_pch(mydocs precomp.hpp SOURCE)
index 2ed3173..4302187 100644 (file)
@@ -1,7 +1,6 @@
 
 project(SHELL)
 
-set_cpp(WITH_RUNTIME)
 
 if(NOT MSVC)
     # HACK: this should be enabled globally!
@@ -41,7 +40,7 @@ add_library(netshell MODULE
     ${CMAKE_CURRENT_BINARY_DIR}/netshell.def)
 
 set_module_type(netshell win32dll UNICODE)
-target_link_libraries(netshell uuid wine)
+target_link_libraries(netshell uuid wine cpprt)
 add_delay_importlibs(netshell ole32 oleaut32 shlwapi shell32)
 add_importlibs(netshell version iphlpapi gdi32 user32 advapi32 setupapi ws2_32 comctl32 msvcrt kernel32 ntdll)
 add_pch(netshell precomp.h "${PCH_SKIP_SOURCE}")
index 3015c64..91132a4 100644 (file)
@@ -4,7 +4,6 @@ project(SHELL)
 add_definitions(
     -D_ATL_NO_EXCEPTIONS)
 
-set_cpp(WITH_RUNTIME)
 
 if(NOT MSVC)
     # HACK: this should be enabled globally!
@@ -33,7 +32,7 @@ add_library(ntobjshex MODULE
     ${CMAKE_CURRENT_BINARY_DIR}/ntobjshex.def)
 
 set_module_type(ntobjshex win32dll UNICODE)
-target_link_libraries(ntobjshex uuid wine)
+target_link_libraries(ntobjshex uuid wine cpprt)
 
 add_importlibs(ntobjshex
     advapi32
index 5112893..52d0a39 100644 (file)
@@ -1,4 +1,3 @@
-set_cpp(WITH_RUNTIME)
 spec2def(sendmail.dll sendmail.spec)
 
 add_definitions(
@@ -28,7 +27,7 @@ add_library(sendmail MODULE
     ${CMAKE_CURRENT_BINARY_DIR}/sendmail.def)
 
 set_module_type(sendmail win32dll UNICODE)
-target_link_libraries(sendmail uuid wine)
+target_link_libraries(sendmail uuid wine cpprt)
 add_delay_importlibs(sendmail ole32 oleaut32)
 add_importlibs(sendmail advapi32 shell32 user32 comctl32 shlwapi msvcrt kernel32 ntdll)
 add_pch(sendmail precomp.hpp SOURCE)
index c8fdc85..7a21c8a 100644 (file)
@@ -1,4 +1,3 @@
-set_cpp(WITH_RUNTIME WITH_EXCEPTIONS WITH_STL)
 
 remove_definitions(-D_WIN32_WINNT=0x502)
 add_definitions(-D_WIN32_WINNT=0x603)
@@ -39,7 +38,8 @@ file(GLOB shellbtrfs_rc_deps *.ico)
 add_rc_deps(shellbtrfs.rc ${shellbtrfs_rc_deps})
 
 set_module_type(shellbtrfs win32dll UNICODE)
-target_link_libraries(shellbtrfs uuid)
+target_link_libraries(shellbtrfs uuid cppstl)
+set_target_cpp_properties(shellbtrfs WITH_EXCEPTIONS)
 add_importlibs(shellbtrfs advapi32 advapi32_vista ole32 shell32 shlwapi user32 comctl32 uxtheme setupapi comdlg32 gdi32 msvcrt kernel32_vista kernel32 ntdll)
 add_pch(shellbtrfs precomp.h "${PCH_SKIP_SOURCE}")
 add_cd_file(TARGET shellbtrfs DESTINATION reactos/system32 FOR all)
index 411dab2..15d9206 100644 (file)
@@ -1,8 +1,6 @@
 
 project(SHELL)
 
-set_cpp(WITH_RUNTIME)
-
 if(NOT MSVC)
     # HACK: this should be enabled globally!
     add_compile_flags_language("-std=c++11" "CXX")
@@ -34,7 +32,7 @@ add_library(stobject MODULE
     ${CMAKE_CURRENT_BINARY_DIR}/stobject.def)
 
 set_module_type(stobject win32dll UNICODE)
-target_link_libraries(stobject uuid wine)
+target_link_libraries(stobject uuid wine cpprt)
 
 add_importlibs(stobject
     setupapi
index f0339f9..4459b9d 100644 (file)
@@ -1,5 +1,4 @@
 
-set_cpp(WITH_RUNTIME WITH_EXCEPTIONS)
 if(NOT MSVC)
     # HACK: this should be enabled globally!
     add_compile_flags_language("-std=c++11" "CXX")
@@ -47,7 +46,8 @@ add_library(zipfldr MODULE
 
 
 set_module_type(zipfldr win32dll UNICODE)
-target_link_libraries(zipfldr minizip zlib uuid)
+target_link_libraries(zipfldr minizip zlib uuid cpprt)
+set_target_cpp_properties(zipfldr WITH_EXCEPTIONS)
 add_importlibs(zipfldr oleaut32 ole32 shlwapi comctl32 shell32 user32 advapi32 msvcrt kernel32 ntdll)
 add_pch(zipfldr precomp.h SOURCE)
 add_cd_file(TARGET zipfldr DESTINATION reactos/system32 FOR all)
index 5c136cd..1aa48b8 100644 (file)
@@ -3,8 +3,6 @@ PROJECT(SHELL)
 add_subdirectory(shellbars)
 add_subdirectory(shellfind)
 
-set_cpp(WITH_RUNTIME)
-
 add_definitions(
     -D_ATL_NO_EXCEPTIONS)
 
@@ -49,7 +47,7 @@ add_library(browseui MODULE
     ${CMAKE_CURRENT_BINARY_DIR}/browseui.def)
 
 set_module_type(browseui win32dll UNICODE)
-target_link_libraries(browseui shellbars shellfind uuid wine)
+target_link_libraries(browseui shellbars shellfind uuid wine cpprt)
 add_importlibs(browseui uxtheme shlwapi shell32 comctl32 gdi32 ole32 oleaut32 user32 advapi32 mpr msvcrt kernel32 ntdll)
 add_pch(browseui precomp.h "${PCH_SKIP_SOURCE}")
 add_cd_file(TARGET browseui DESTINATION reactos/system32 FOR all)
@@ -62,8 +60,8 @@ if(NOT MSVC)
     endif()
 endif()
 
-add_custom_command(TARGET browseui POST_BUILD 
-  COMMAND "${CMAKE_COMMAND}" -E copy 
+add_custom_command(TARGET browseui POST_BUILD
+  COMMAND "${CMAKE_COMMAND}" -E copy
      "$<TARGET_FILE:browseui>"
-     "$<TARGET_FILE_DIR:filebrowser>/$<TARGET_FILE_NAME:browseui>" 
+     "$<TARGET_FILE_DIR:filebrowser>/$<TARGET_FILE_NAME:browseui>"
   COMMENT "Copying to output directory")
index 661284c..221de17 100644 (file)
@@ -1,8 +1,6 @@
 
 PROJECT(SHELL)
 
-set_cpp(WITH_RUNTIME)
-
 add_definitions(-DUNICODE -D_UNICODE)
 add_definitions(-D_ATL_NO_EXCEPTIONS)
 
index 0d7fd02..5900ed9 100644 (file)
@@ -1,8 +1,6 @@
 
 PROJECT(SHELL)
 
-set_cpp(WITH_RUNTIME)
-
 add_definitions(-DUNICODE -D_UNICODE)
 add_definitions(-D_ATL_NO_EXCEPTIONS)
 
index 88b2475..f805b3f 100644 (file)
@@ -2,8 +2,6 @@ PROJECT(DEVMGR)
 
 spec2def(devmgr.dll devmgr.spec ADD_IMPORTLIB)
 
-set_cpp(WITH_RTTI WITH_RUNTIME WITH_EXCEPTIONS)
-
 if(NOT MSVC)
     # HACK: this should be enabled globally!
     add_compile_flags_language("-std=c++11" "CXX")
@@ -11,7 +9,7 @@ endif()
 
 include_directories(
     ${REACTOS_SOURCE_DIR}/sdk/include/reactos/dll
-    ${REACTOS_SOURCE_DIR}/sdk/lib/atl 
+    ${REACTOS_SOURCE_DIR}/sdk/lib/atl
     includes)
 
 list(APPEND SOURCE
@@ -35,7 +33,8 @@ add_library(devmgr MODULE
     ${CMAKE_CURRENT_BINARY_DIR}/devmgr.def)
 
 set_module_type(devmgr win32dll UNICODE)
-target_link_libraries(devmgr uuid wine)
+target_link_libraries(devmgr uuid wine cpprt)
+set_target_cpp_properties(devmgr WITH_EXCEPTIONS WITH_RTTI)
 add_importlibs(devmgr setupapi advapi32 shell32 newdev user32 gdi32 comctl32 version msvcrt kernel32 ole32 oleaut32 uxtheme ntdll)
 add_pch(devmgr precomp.h SOURCE)
 add_cd_file(TARGET devmgr DESTINATION reactos/system32 FOR all)
index edc6ab7..922ead7 100644 (file)
@@ -1,5 +1,4 @@
 
-set_cpp(WITH_RUNTIME WITH_EXCEPTIONS)
 spec2def(framedyn.dll framedyn.spec ADD_IMPORTLIB)
 
 list(APPEND SOURCE
@@ -13,6 +12,8 @@ if(MSVC)
 endif()
 
 add_library(framedyn MODULE ${SOURCE})
+target_link_libraries(framedyn cpprt)
+set_target_cpp_properties(framedyn WITH_EXCEPTIONS)
 set_module_type(framedyn win32dll UNICODE)
 add_importlibs(framedyn oleaut32 msvcrt kernel32 ntdll)
 add_cd_file(TARGET framedyn DESTINATION reactos/system32/wbem FOR all)
index 5f3fa9e..056b602 100644 (file)
@@ -1,5 +1,4 @@
 
-set_cpp(WITH_RUNTIME)
 
 add_definitions(
     -D_ATL_NO_EXCEPTIONS)
@@ -29,7 +28,7 @@ add_library(msgina MODULE
     ${CMAKE_CURRENT_BINARY_DIR}/msgina.def)
 
 set_module_type(msgina win32dll UNICODE)
-target_link_libraries(msgina wine uuid ${PSEH_LIB})
+target_link_libraries(msgina wine uuid ${PSEH_LIB} cpprt)
 add_delay_importlibs(msgina secur32)
 add_importlibs(msgina advapi32 user32 gdi32 powrprof userenv msvcrt kernel32 ntdll)
 add_pch(msgina msgina.h "${PCH_SKIP_SOURCE}")
index 5c812e9..a76c13a 100644 (file)
@@ -4,7 +4,6 @@ add_subdirectory(shelldesktop)
 add_subdirectory(shellmenu)
 add_subdirectory(shellrecyclebin)
 
-set_cpp(WITH_RUNTIME)
 spec2def(shell32.dll shell32.spec ADD_IMPORTLIB)
 
 if(NOT MSVC)
@@ -122,7 +121,7 @@ add_typelib(shell32_shldisp.idl)
 set_source_files_properties(shell32.rc PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/shell32_shldisp.tlb)
 
 set_module_type(shell32 win32dll UNICODE)
-target_link_libraries(shell32 shellmenu shelldesktop wine uuid recyclebin)
+target_link_libraries(shell32 shellmenu shelldesktop wine uuid recyclebin cpprt)
 add_delay_importlibs(shell32 powrprof shdocvw devmgr winspool.drv winmm mpr uxtheme ole32 oleaut32 userenv browseui version fmifs)
 add_importlibs(shell32 advapi32 gdi32 user32 comctl32 comdlg32 shlwapi msvcrt kernel32 ntdll)
 add_dependencies(shell32 stdole2) # shell32_shldisp.tlb needs stdole2.tlb
index 2ea167b..7da3e7b 100644 (file)
@@ -1,7 +1,5 @@
 project(SHELL)
 
-set_cpp(WITH_RUNTIME)
-
 add_definitions(
     -DUNICODE
     -D_UNICODE
index ebca89a..94c04fc 100644 (file)
@@ -1,7 +1,5 @@
 project(SHELL)
 
-set_cpp(WITH_RUNTIME)
-
 add_definitions(
     -DUNICODE
     -D_UNICODE
index 6c425e7..0e166a3 100644 (file)
@@ -9,7 +9,6 @@ add_definitions(
     -D_SHLWAPI_
     -D_ATL_NO_EXCEPTIONS)
 
-set_cpp(WITH_RUNTIME)
 include_directories(BEFORE
     ${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine
     ${REACTOS_SOURCE_DIR}/sdk/lib/atl)
index 8c13bf7..292fe24 100644 (file)
@@ -1,8 +1,6 @@
 
 include_directories(Include)
 
-set_cpp(WITH_RUNTIME)
-
 list(APPEND SOURCE
     udf_info/alloc.cpp
     udf_info/dirtree.cpp
index 1631748..f8f952a 100644 (file)
@@ -1,5 +1,4 @@
 
-set_cpp()
 
 include_directories(
     BEFORE ${CMAKE_CURRENT_SOURCE_DIR}
index 2262caa..218eaec 100644 (file)
@@ -1,5 +1,4 @@
 
-set_cpp()
 
 remove_definitions(-D_WIN32_WINNT=0x502)
 add_definitions(-D_WIN32_WINNT=0x600)
index 294b48c..a873b75 100644 (file)
@@ -1,5 +1,4 @@
 
-set_cpp()
 
 remove_definitions(-D_WIN32_WINNT=0x502)
 add_definitions(-D_WIN32_WINNT=0x600)
index ba6cd3f..564c5e4 100644 (file)
@@ -2,7 +2,6 @@
 add_subdirectory(cmicontrol)
 add_subdirectory(cpl)
 
-set_cpp()
 
 # for WaveRT support
 remove_definitions(-D_WIN32_WINNT=0x502)
index 3c5883d..d129c3e 100644 (file)
@@ -1,5 +1,4 @@
 
-set_cpp()
 
 remove_definitions(-D_WIN32_WINNT=0x502)
 add_definitions(-D_WIN32_WINNT=0x600)
index e3b71b4..b427fdd 100644 (file)
@@ -1,6 +1,6 @@
 
-set_cpp(WITH_RUNTIME)
 add_executable(gdb2 gdb2.cpp)
+target_link_libraries(gdb2 cpprt)
 set_module_type(gdb2 win32cui)
 add_importlibs(gdb2 user32 msvcrt kernel32)
 add_cd_file(TARGET gdb2 DESTINATION reactos/system32 FOR all)
index 2322440..2f6541b 100644 (file)
@@ -1,5 +1,4 @@
 
-set_cpp(WITH_RUNTIME)
 add_definitions(-D_ATL_NO_EXCEPTIONS)
 
 include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/atl)
@@ -7,6 +6,6 @@ include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/atl)
 add_executable(shlextdbg shlextdbg.cpp shlextdbg.rc)
 
 set_module_type(shlextdbg win32cui UNICODE)
-target_link_libraries(shlextdbg uuid)
+target_link_libraries(shlextdbg uuid cpprt)
 add_importlibs(shlextdbg ole32 comctl32 shell32 user32 msvcrt kernel32)
 add_cd_file(TARGET shlextdbg DESTINATION reactos/system32 FOR all)
index ca824c4..82c7d75 100644 (file)
@@ -1,8 +1,6 @@
 
 add_subdirectory(notifyhook)
 
-set_cpp(WITH_RTTI WITH_EXCEPTIONS WITH_STL)
-
 add_definitions(
     -DWIN32
     -D__WINDRES__)
@@ -53,7 +51,8 @@ add_executable(explorer_old
     ${PCH_SKIP_SOURCE}
     explorer.rc)
 
-target_link_libraries(explorer_old comsupp wine uuid)
+target_link_libraries(explorer_old comsupp wine uuid cppstl)
+set_target_cpp_properties(explorer_old WITH_EXCEPTIONS WITH_RTTI)
 set_module_type(explorer_old win32gui UNICODE)
 add_importlibs(explorer_old advapi32 gdi32 user32 ws2_32 msimg32 comctl32 ole32 oleaut32 shell32 shlwapi notifyhook msvcrt kernel32 ntdll)
 add_pch(explorer_old precomp.h "${PCH_SKIP_SOURCE}")
index 7526d90..17d7d28 100644 (file)
@@ -1,6 +1,4 @@
 
-set_cpp(WITH_RUNTIME WITH_STL WITH_EXCEPTIONS)
-
 list(APPEND SOURCE
        Fraginator.cpp
        MainDialog.cpp
@@ -12,12 +10,16 @@ list(APPEND UNFRAG_SOURCE
        DriveVolume.cpp)
 
 add_executable(frag ${SOURCE} ${UNFRAG_SOURCE} Fraginator.rc)
+target_link_libraries(frag cppstl)
+set_target_cpp_properties(frag WITH_EXCEPTIONS)
 set_module_type(frag win32gui UNICODE)
 add_importlibs(frag user32 advapi32 shell32 comctl32 msvcrt kernel32 ntdll)
 add_cd_file(TARGET frag DESTINATION reactos/system32 FOR all)
 
 add_executable(unfrag ${UNFRAG_SOURCE})
+target_link_libraries(unfrag cppstl)
+set_target_cpp_properties(unfrag WITH_EXCEPTIONS)
 target_compile_definitions(unfrag PRIVATE "_CUI_")
 set_module_type(unfrag win32cui UNICODE)
 add_importlibs(unfrag advapi32 msvcrt kernel32 ntdll)
-add_cd_file(TARGET unfrag DESTINATION reactos/system32 FOR all)
\ No newline at end of file
+add_cd_file(TARGET unfrag DESTINATION reactos/system32 FOR all)
index 3642568..3f1f178 100644 (file)
@@ -1,6 +1,7 @@
 
-set_cpp(WITH_RUNTIME WITH_STL WITH_EXCEPTIONS)
 add_executable(netreg netreg.cpp netreg.rc)
+target_link_libraries(netreg cppstl)
+set_target_cpp_properties(netreg WITH_EXCEPTIONS)
 set_module_type(netreg win32cui)
 add_importlibs(netreg advapi32 user32 ws2_32 msvcrt kernel32 ntdll)
 add_cd_file(TARGET netreg DESTINATION reactos/system32 FOR all)
index 72e02da..3cb2276 100644 (file)
@@ -1,5 +1,4 @@
 
-set_cpp(WITH_RUNTIME WITH_STL WITH_EXCEPTIONS)
 include_directories(BEFORE include)
 add_compile_flags("-D__USE_W32_SOCKETS")
 
@@ -14,6 +13,8 @@ list(APPEND SOURCE
     common/thread.cpp)
 
 add_executable(roshttpd ${SOURCE} common/roshttpd.rc)
+target_link_libraries(roshttpd cppstl)
+set_target_cpp_properties(roshttpd WITH_EXCEPTIONS)
 set_module_type(roshttpd win32cui)
 add_importlibs(roshttpd user32 ws2_32 msvcrt kernel32)
 add_cd_file(TARGET roshttpd DESTINATION reactos/system32 FOR all)
index 09e1c73..b24ae31 100644 (file)
@@ -1,16 +1,17 @@
 # FontSub by Katayama Hirofumi MZ
-# 
+#
 # To the extent possible under law, the person who associated CC0 with
 # FontSub has waived all copyright and related or neighboring rights
 # to FontSub.
-# 
+#
 # You should have received a copy of the CC0 legalcode along with this
 # work.  If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
 
-set_cpp(WITH_RUNTIME WITH_STL WITH_EXCEPTIONS)
-
 add_executable(fontsubedit fontsub.cpp fontsub_res.rc)
+target_link_libraries(fontsubedit cppstl)
 set_module_type(fontsubedit win32gui UNICODE)
 add_importlibs(fontsubedit advapi32 comctl32 comdlg32 shell32 gdi32 user32 msvcrt kernel32)
-set_target_properties(fontsubedit PROPERTIES OUTPUT_NAME "fontsub")
+set_target_cpp_properties(fontsubedit WITH_EXCEPTIONS)
+set_target_properties(fontsubedit PROPERTIES
+    OUTPUT_NAME "fontsub")
 add_cd_file(TARGET fontsubedit DESTINATION reactos/system32 FOR all)
index 2b76738..1cd493d 100644 (file)
@@ -1,6 +1,4 @@
 
-set_cpp(WITH_RUNTIME WITH_STL WITH_EXCEPTIONS)
-
 list(APPEND SOURCE
     ArgumentParser.cpp
     Console.cpp
@@ -31,6 +29,8 @@ list(APPEND SOURCE
     Prompt.cpp)
 
 add_executable(regexpl ${SOURCE} regexpl.rc)
+target_link_libraries(regexpl cppstl)
+set_target_cpp_properties(regexpl WITH_EXCEPTIONS)
 set_module_type(regexpl win32cui)
 add_importlibs(regexpl user32 advapi32 msvcrt kernel32 ntdll)
 add_cd_file(TARGET regexpl DESTINATION reactos/system32 FOR all)
index 9dcf932..d1c5946 100644 (file)
@@ -1,4 +1,3 @@
-set_cpp(WITH_RUNTIME WITH_EXCEPTIONS WITH_STL)
 
 spec2def(vfd.dll vfdlib.spec ADD_IMPORTLIB)
 
@@ -31,7 +30,8 @@ add_library(vfd MODULE
 include_directories(${REACTOS_SOURCE_DIR}/modules/rosapps/include/vfd
                     ${REACTOS_SOURCE_DIR}/sdk/include/reactos/libs/zlib)
 set_module_type(vfd win32dll ENTRYPOINT DllMain 12)
-target_link_libraries(vfd zlib_solo uuid)
+target_link_libraries(vfd zlib_solo uuid cppstl)
+set_target_cpp_properties(vfd WITH_EXCEPTIONS)
 add_importlibs(vfd advapi32 user32 gdi32 shell32 comdlg32 comctl32 ole32 version psapi msvcrt kernel32 ntdll)
 add_dependencies(vfd vfdmsg_lib)
 add_cd_file(TARGET vfd DESTINATION reactos/system32 FOR all)
index 5a17d8c..6bf9ddc 100644 (file)
@@ -7,7 +7,6 @@ add_definitions(
     -D_UNICODE
     -D_ATL_NO_EXCEPTIONS)
 
-set_cpp(WITH_RUNTIME)
 
 include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/atl
                     ${CMAKE_CURRENT_BINARY_DIR})
@@ -26,10 +25,10 @@ list(APPEND SOURCE
 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/testdb.sdb
                    COMMAND native-xml2sdb -i ${CMAKE_CURRENT_SOURCE_DIR}/testdb.xml -o ${CMAKE_CURRENT_BINARY_DIR}/testdb.sdb
                    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/testdb.xml native-xml2sdb)
-                   
+
 add_rc_deps(testdata.rc ${CMAKE_CURRENT_BINARY_DIR}/testdb.sdb)
 add_executable(apphelp_apitest ${SOURCE})
 set_module_type(apphelp_apitest win32cui)
-target_link_libraries(apphelp_apitest ${PSEH_LIB})
+target_link_libraries(apphelp_apitest ${PSEH_LIB} cpprt)
 add_importlibs(apphelp_apitest advapi32 userenv version shlwapi msvcrt kernel32 ntdll)
 add_rostests_file(TARGET apphelp_apitest)
index c0c3781..11ca2fd 100644 (file)
@@ -1,6 +1,5 @@
 
 add_definitions(-DINITGUID -DWINETEST_USE_DBGSTR_LONGLONG)
-set_cpp(WITH_RUNTIME WITH_EXCEPTIONS)
 
 include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/atl)
 
@@ -29,7 +28,8 @@ add_executable(atl_apitest
     ${PCH_SKIP_SOURCE}
     atl_apitest.rc)
 
-target_link_libraries(atl_apitest wine uuid)
+target_link_libraries(atl_apitest wine uuid cpprt)
+set_target_cpp_properties(atl_apitest WITH_EXCEPTIONS)
 set_module_type(atl_apitest win32cui)
 add_importlibs(atl_apitest rpcrt4 ole32 oleaut32 msimg32 gdi32 advapi32 user32 msvcrt kernel32 ntdll)
 add_pch(atl_apitest precomp.h "${PCH_SKIP_SOURCE}")
index 053ca97..2ae9cc3 100644 (file)
@@ -1,12 +1,11 @@
 
-set_cpp(WITH_RTTI WITH_RUNTIME WITH_EXCEPTIONS)
 if(NOT MSVC)
     # HACK: this should be enabled globally!
     add_compile_flags_language("-std=c++11" "CXX")
 endif()
 
 include_directories(
-    ${REACTOS_SOURCE_DIR}/sdk/lib/atl 
+    ${REACTOS_SOURCE_DIR}/sdk/lib/atl
     includes)
 
 list(APPEND SOURCE
@@ -17,7 +16,9 @@ list(APPEND SOURCE
     testlist.c)
 
 add_executable(browseui_apitest ${SOURCE})
-target_link_libraries(browseui_apitest uuid wine)
+target_link_libraries(browseui_apitest uuid wine cpprt)
+
+set_target_cpp_properties(browseui_apitest WITH_EXCEPTIONS WITH_RTTI)
 set_module_type(browseui_apitest win32cui)
 add_importlibs(browseui_apitest advapi32 shell32 ole32 shlwapi msvcrt kernel32 ntdll)
 add_rostests_file(TARGET browseui_apitest)
index 80654e4..aca32f4 100644 (file)
@@ -6,7 +6,6 @@ add_definitions(
     -D_UNICODE
     -D_ATL_NO_EXCEPTIONS)
 
-set_cpp(WITH_RUNTIME)
 
 include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/atl
                     ${CMAKE_CURRENT_BINARY_DIR})
@@ -17,6 +16,6 @@ list(APPEND SOURCE
 
 add_executable(fontext_apitest ${SOURCE})
 set_module_type(fontext_apitest win32cui)
-target_link_libraries(fontext_apitest uuid ${PSEH_LIB})
+target_link_libraries(fontext_apitest uuid ${PSEH_LIB} cpprt)
 add_importlibs(fontext_apitest oleaut32 ole32 shell32 user32 msvcrt kernel32 ntdll)
 add_rostests_file(TARGET fontext_apitest)
index 0d64a0c..9b87377 100644 (file)
@@ -2,7 +2,6 @@
 add_definitions(
     -D_ATL_NO_EXCEPTIONS)
 
-set_cpp(WITH_RUNTIME)
 
 include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/atl)
 
@@ -10,7 +9,7 @@ add_executable(msgina_apitest
     ShellDimScreen.cpp
     testlist.c)
 
-target_link_libraries(msgina_apitest wine uuid)
+target_link_libraries(msgina_apitest wine uuid cpprt)
 set_module_type(msgina_apitest win32cui)
 add_importlibs(msgina_apitest msvcrt user32 kernel32)
 add_rostests_file(TARGET msgina_apitest)
index 4f6ad2d..d321286 100644 (file)
@@ -1,7 +1,6 @@
 
-set_cpp(WITH_RUNTIME)
 add_executable(ole32_apitest initializespy.cpp testlist.c)
-target_link_libraries(ole32_apitest wine uuid)
+target_link_libraries(ole32_apitest wine uuid cpprt)
 set_module_type(ole32_apitest win32cui)
 add_importlibs(ole32_apitest user32 gdi32 shell32 ole32 shlwapi msvcrt kernel32)
 add_rostests_file(TARGET ole32_apitest)
index f719ab6..39c81e5 100644 (file)
@@ -2,8 +2,6 @@
 add_definitions(
     -D_ATL_NO_EXCEPTIONS)
 
-set_cpp(WITH_RUNTIME)
-
 spec2def(shell32_apitest.exe shell32_apitest.spec)
 
 include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/atl)
@@ -46,7 +44,7 @@ add_executable(shell32_apitest
     resource.rc
     ${CMAKE_CURRENT_BINARY_DIR}/shell32_apitest.def)
 
-target_link_libraries(shell32_apitest wine uuid ${PSEH_LIB})
+target_link_libraries(shell32_apitest wine uuid ${PSEH_LIB} cpprt)
 set_module_type(shell32_apitest win32cui)
 add_importlibs(shell32_apitest user32 gdi32 shell32 ole32 oleaut32 advapi32 shlwapi msvcrt kernel32 ntdll)
 add_pch(shell32_apitest shelltest.h "${PCH_SKIP_SOURCE}")
@@ -54,6 +52,7 @@ add_rostests_file(TARGET shell32_apitest)
 
 # shell-notify.exe
 add_executable(shell-notify shell-notify.cpp)
+target_link_libraries(shell-notify cpprt)
 set_module_type(shell-notify win32gui UNICODE)
 add_importlibs(shell-notify msvcrt kernel32 user32 shell32 shlwapi ole32)
 add_rostests_file(TARGET shell-notify SUBDIR testdata)
index 63da688..9bda3bd 100644 (file)
@@ -1,7 +1,4 @@
 
-add_definitions(-DINITGUID -DWINETEST_USE_DBGSTR_LONGLONG)
-set_cpp(WITH_RUNTIME WITH_EXCEPTIONS)
-
 include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/atl)
 
 list(APPEND SOURCE
@@ -17,7 +14,8 @@ add_executable(zipfldr_apitest
     ${PCH_SKIP_SOURCE}
     zipfldr_apitest.rc)
 
-target_link_libraries(zipfldr_apitest wine uuid)
+target_link_libraries(zipfldr_apitest wine uuid cpprt)
+set_target_cpp_properties(zipfldr_apitest WITH_EXCEPTIONS)
 set_module_type(zipfldr_apitest win32cui)
 add_importlibs(zipfldr_apitest shlwapi ole32 shell32 user32 msvcrt kernel32 ntdll)
 add_pch(zipfldr_apitest precomp.h "${PCH_SKIP_SOURCE}")
index 21f0cdd..5d82a95 100644 (file)
@@ -1,6 +1,4 @@
 
-set_cpp(WITH_EXCEPTIONS WITH_STL)
-
 list(APPEND SOURCE
     CConfiguration.cpp
     CFatalException.cpp
@@ -21,6 +19,8 @@ list(APPEND SOURCE
     precomp.h)
 
 add_executable(rosautotest ${SOURCE} ${CMAKE_CURRENT_BINARY_DIR}/rosautotestmsg.rc)
+target_link_libraries(rosautotest cppstl)
+set_target_cpp_properties(rosautotest WITH_EXCEPTIONS)
 set_module_type(rosautotest win32cui UNICODE)
 add_importlibs(rosautotest advapi32 shell32 user32 wininet msvcrt kernel32 ntdll)
 add_pch(rosautotest precomp.h SOURCE)
index fa408d7..707a6b2 100644 (file)
@@ -1,86 +1,4 @@
 
-# set_cpp
-#  Marks the current folder as containing C++ modules, additionally enabling
-#  specific C++ language features as specified (all of these default to off):
-#
-#  WITH_RUNTIME
-#   Links with the C++ runtime. Enable this for modules which use new/delete or
-#   RTTI, but do not require STL. This is the right choice if you see undefined
-#   references to operator new/delete, vector constructor/destructor iterator,
-#   type_info::vtable, ...
-#   Note: this only affects linking, so cannot be used for static libraries.
-#  WITH_RTTI
-#   Enables run-time type information. Enable this if the module uses typeid or
-#   dynamic_cast. You will probably need to enable WITH_RUNTIME as well, if
-#   you're not already using STL.
-#  WITH_EXCEPTIONS
-#   Enables C++ exception handling. Enable this if the module uses try/catch or
-#   throw. You might also need this if you use a standard operator new (the one
-#   without nothrow).
-#  WITH_STL
-#   Enables standard C++ headers and links to the Standard Template Library.
-#   Use this for modules using anything from the std:: namespace, e.g. maps,
-#   strings, vectors, etc.
-#   Note: this affects both compiling (via include directories) and
-#         linking (by adding STL). Implies WITH_RUNTIME.
-#   FIXME: WITH_STL is currently also required for runtime headers such as
-#          <new> and <exception>. This is not a big issue because in stl-less
-#          environments you usually don't want those anyway; but we might want
-#          to have modules like this in the future.
-#
-# Examples:
-#  set_cpp()
-#   Enables the C++ language, but will cause errors if any runtime or standard
-#   library features are used. This should be the default for C++ in kernel
-#   mode or otherwise restricted environments.
-#   Note: this is required to get libgcc (for multiplication/division) linked
-#         in for C++ modules, and to set the correct language for precompiled
-#         header files, so it IS required even with no features specified.
-#  set_cpp(WITH_RUNTIME)
-#   Links with the C++ runtime, so that e.g. custom operator new implementations
-#   can be used in a restricted environment. This is also required for linking
-#   with libraries (such as ATL) which have RTTI enabled, even if the module in
-#   question does not use WITH_RTTI.
-#  set_cpp(WITH_RTTI WITH_EXCEPTIONS WITH_STL)
-#   The full package. This will adjust compiler and linker so that all C++
-#   features can be used.
-macro(set_cpp)
-    cmake_parse_arguments(__cppopts "WITH_RUNTIME;WITH_RTTI;WITH_EXCEPTIONS;WITH_STL" "" "" ${ARGN})
-    if(__cppopts_UNPARSED_ARGUMENTS)
-        message(FATAL_ERROR "set_cpp: unparsed arguments ${__cppopts_UNPARSED_ARGUMENTS}")
-    endif()
-
-    if(__cppopts_WITH_RUNTIME)
-        set(CPP_USE_RT 1)
-    endif()
-    if(__cppopts_WITH_RTTI)
-        if(MSVC)
-            replace_compile_flags("/GR-" "/GR")
-        else()
-            replace_compile_flags_language("-fno-rtti" "-frtti" "CXX")
-        endif()
-    endif()
-    if(__cppopts_WITH_EXCEPTIONS)
-        if(MSVC)
-            replace_compile_flags("/EHs-c-" "/EHsc")
-        else()
-            replace_compile_flags_language("-fno-exceptions" "-fexceptions" "CXX")
-        endif()
-    endif()
-    if(__cppopts_WITH_STL)
-        set(CPP_USE_STL 1)
-        if(MSVC)
-            add_definitions(-DNATIVE_CPP_INCLUDE=${REACTOS_SOURCE_DIR}/sdk/include/c++)
-            include_directories(${REACTOS_SOURCE_DIR}/sdk/include/c++/stlport)
-        else()
-            replace_compile_flags("-nostdinc" " ")
-            add_definitions(-DPAL_STDCPP_COMPAT)
-        endif()
-    endif()
-
-    set(IS_CPP 1)
-endmacro()
-
 function(add_dependency_node _node)
     if(GENERATE_DEPENDENCY_GRAPH)
         get_target_property(_type ${_node} TYPE)
@@ -988,3 +906,15 @@ else()
     macro(add_pch _target _pch _skip_list)
     endmacro()
 endif()
+
+function(set_target_cpp_properties _target)
+    cmake_parse_arguments(_CPP "WITH_EXCEPTIONS;WITH_RTTI" "" "" ${ARGN})
+
+    if (_CPP_WITH_EXCEPTIONS)
+        set_target_properties(${_target} PROPERTIES WITH_CXX_EXCEPTIONS TRUE)
+    endif()
+
+    if (_CPP_WITH_RTTI)
+        set_target_properties(${_target} PROPERTIES WITH_CXX_RTTI TRUE)
+    endif()
+endfunction()
index 1abe186..cf72bae 100644 (file)
@@ -41,8 +41,9 @@ endif()
 # Compiler Core
 add_compile_flags("-pipe -fms-extensions -fno-strict-aliasing")
 
-# Prevent GCC from searching any of the default directories
-add_compile_flags("-nostdinc")
+# Prevent GCC from searching any of the default directories.
+# The case for C++ is handled through the reactos_c++ INTERFACE library
+add_compile_options("$<$<NOT:$<COMPILE_LANGUAGE:CXX>>:-nostdinc>")
 
 add_compile_flags("-mstackrealign")
 add_compile_flags("-fno-aggressive-loop-optimizations")
@@ -68,8 +69,6 @@ if(DBG)
     endif()
 endif()
 
-add_compile_flags_language("-fno-rtti -fno-exceptions" "CXX")
-
 #bug
 #file(TO_NATIVE_PATH ${REACTOS_SOURCE_DIR} REACTOS_SOURCE_DIR_NATIVE)
 #workaround
@@ -292,17 +291,6 @@ function(set_image_base MODULE IMAGE_BASE)
 endfunction()
 
 function(set_module_type_toolchain MODULE TYPE)
-    if(CPP_USE_STL)
-        if((${TYPE} STREQUAL "kernelmodedriver") OR (${TYPE} STREQUAL "wdmdriver"))
-            message(FATAL_ERROR "Use of STL in kernelmodedriver or wdmdriver type module prohibited")
-        endif()
-        target_link_libraries(${MODULE} -lstdc++ -lsupc++ -lgcc -lmingwex)
-    elseif(CPP_USE_RT)
-        target_link_libraries(${MODULE} -lsupc++ -lgcc)
-    elseif(IS_CPP)
-        target_link_libraries(${MODULE} -lgcc)
-    endif()
-
     if((${TYPE} STREQUAL "kernelmodedriver") OR (${TYPE} STREQUAL "wdmdriver"))
         add_target_link_flags(${MODULE} "-Wl,--exclude-all-symbols,-file-alignment=0x1000,-section-alignment=0x1000")
         if(${TYPE} STREQUAL "wdmdriver")
@@ -440,3 +428,47 @@ function(add_linker_script _target _linker_script_file)
     add_target_link_flags(${_target} "-Wl,-T,${_file_full_path}")
     add_target_property(${_target} LINK_DEPENDS ${_file_full_path})
 endfunction()
+
+# Manage our C++ options
+# we disable standard includes if we don't use the STL
+add_compile_options("$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<NOT:$<IN_LIST:cppstl,$<TARGET_PROPERTY:LINK_LIBRARIES>>>>:-nostdinc>")
+# we disable RTTI, unless said so
+add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:$<IF:$<BOOL:$<TARGET_PROPERTY:WITH_CXX_RTTI>>,-frtti,-fno-rtti>>")
+# We disable exceptions, unless said so
+add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:$<IF:$<BOOL:$<TARGET_PROPERTY:WITH_CXX_EXCEPTIONS>>,-fexceptions,-fno-exceptions>>")
+
+# Find default G++ libraries
+add_library(libgcc STATIC IMPORTED)
+execute_process(COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=libgcc.a OUTPUT_VARIABLE LIBGCC_LOCATION)
+string(STRIP ${LIBGCC_LOCATION} LIBGCC_LOCATION)
+set_target_properties(libgcc PROPERTIES IMPORTED_LOCATION ${LIBGCC_LOCATION})
+# libgcc needs kernel32 imports, a CRT and msvcrtex
+target_link_libraries(libgcc INTERFACE libkernel32 libmsvcrt msvcrtex)
+
+add_library(libsupc++ STATIC IMPORTED GLOBAL)
+execute_process(COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=libsupc++.a OUTPUT_VARIABLE LIBSUPCXX_LOCATION)
+string(STRIP ${LIBSUPCXX_LOCATION} LIBSUPCXX_LOCATION)
+set_target_properties(libsupc++ PROPERTIES IMPORTED_LOCATION ${LIBSUPCXX_LOCATION})
+# libsupc++ requires libgcc
+target_link_libraries(libsupc++ INTERFACE libgcc)
+
+add_library(libmingwex STATIC IMPORTED)
+execute_process(COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=libmingwex.a OUTPUT_VARIABLE LIBMINGWEX_LOCATION)
+string(STRIP ${LIBMINGWEX_LOCATION} LIBMINGWEX_LOCATION)
+set_target_properties(libmingwex PROPERTIES IMPORTED_LOCATION ${LIBMINGWEX_LOCATION})
+# libmingwex requires a CRT and imports from kernel32
+target_link_libraries(libmingwex INTERFACE libmsvcrt libkernel32)
+
+add_library(libstdc++ STATIC IMPORTED GLOBAL)
+execute_process(COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=libstdc++.a OUTPUT_VARIABLE LIBSTDCCXX_LOCATION)
+string(STRIP ${LIBSTDCCXX_LOCATION} LIBSTDCCXX_LOCATION)
+set_target_properties(libstdc++ PROPERTIES IMPORTED_LOCATION ${LIBSTDCCXX_LOCATION})
+# libstdc++ requires libsupc++ and mingwex provided by GCC
+target_link_libraries(libstdc++ INTERFACE libsupc++ libmingwex)
+# this is for our SAL annotations
+target_compile_definitions(libstdc++ INTERFACE "$<$<COMPILE_LANGUAGE:CXX>:PAL_STDCPP_COMPAT>")
+
+# Create our alias libraries
+add_library(cppstl ALIAS libstdc++)
+add_library(cpprt ALIAS libsupc++)
+
index e189908..3731ca4 100644 (file)
@@ -42,7 +42,7 @@ endif()
 
 # Disable RTTI, exception handling and buffer security checks by default.
 # These require run-time support that may not always be available.
-add_compile_flags("/GR- /EHs-c- /GS-")
+add_compile_flags("/GS-")
 
 if(USE_CLANG_CL)
     set(CMAKE_CL_SHOWINCLUDES_PREFIX "Note: including file: ")
@@ -252,14 +252,6 @@ function(set_image_base MODULE IMAGE_BASE)
 endfunction()
 
 function(set_module_type_toolchain MODULE TYPE)
-    if(CPP_USE_STL)
-        if((${TYPE} STREQUAL "kernelmodedriver") OR (${TYPE} STREQUAL "wdmdriver"))
-            message(FATAL_ERROR "Use of STL in kernelmodedriver or wdmdriver type module prohibited")
-        endif()
-        target_link_libraries(${MODULE} cpprt stlport oldnames)
-    elseif(CPP_USE_RT)
-        target_link_libraries(${MODULE} cpprt)
-    endif()
     if((${TYPE} STREQUAL "win32dll") OR (${TYPE} STREQUAL "win32ocx") OR (${TYPE} STREQUAL "cpl"))
         add_target_link_flags(${MODULE} "/DLL")
     elseif(${TYPE} STREQUAL "kernelmodedriver")
@@ -559,3 +551,17 @@ function(add_linker_script _target _linker_script_file)
         add_target_property(${_target} LINK_DEPENDS ${_file_full_path})
     endif()
 endfunction()
+
+# 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
index ae24230..1a90575 100644 (file)
@@ -1,5 +1,4 @@
 
-set_cpp()
 
 list(APPEND SOURCE
     cardbitmaps.cpp
@@ -15,7 +14,9 @@ list(APPEND SOURCE
     dropzone.cpp
     cardlib.h)
 
-add_library(cardlib ${SOURCE})
+add_library(cardlib STATIC ${SOURCE})
+target_link_libraries(cardlib PRIVATE cpprt)
+target_include_directories(cardlib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
 
 if(NOT MSVC)
     target_compile_options(cardlib PRIVATE "-Wno-unused-but-set-variable")
index 865475f..b2f245b 100644 (file)
@@ -2,13 +2,6 @@
 #uncomment this if you want to test c++ compilation
 #add_subdirectory(test)
 
-set_cpp(WITH_RTTI WITH_EXCEPTIONS WITH_STL)
-
-add_definitions(
-    -D_STLP_USE_EXCEPTIONS
-    -D_DLL -D__USE_CRTIMP
-    -D_BUILD_STLPORT)
-
 list(APPEND SOURCE
     src/allocators.cpp
     src/bitset.cpp
@@ -53,5 +46,14 @@ if(USE_CLANG_CL)
     target_compile_options(stlport PRIVATE -Wno-tautological-unsigned-zero-compare)
 endif()
 
+target_include_directories(stlport PRIVATE ${REACTOS_SOURCE_DIR}/sdk/include/c++/stlport)
+target_compile_definitions(stlport PRIVATE
+    _STLP_USE_EXCEPTIONS _DLL __USE_CRTIMP
+    _BUILD_STLPORT NATIVE_CPP_INCLUDE=${REACTOS_SOURCE_DIR}/sdk/include/c++)
+
+target_include_directories(stlport INTERFACE "$<$<COMPILE_LANGUAGE:CXX>:${REACTOS_SOURCE_DIR}/sdk/include/c++/stlport>")
+target_compile_definitions(stlport INTERFACE "$<$<COMPILE_LANGUAGE:CXX>:NATIVE_CPP_INCLUDE=${REACTOS_SOURCE_DIR}/sdk/include/c++>")
+set_target_cpp_properties(stlport WITH_EXCEPTIONS WITH_RTTI)
+
 add_dependencies(stlport xdk)
 add_pch(stlport src/stlport_prefix.h SOURCE)
index 52b7831..885d098 100644 (file)
@@ -1,4 +1,6 @@
 
-set_cpp(WITH_EXCEPTIONS WITH_STL)
 add_library(comsupp comsupp.cpp)
+target_link_libraries(comsupp PRIVATE cppstl)
+set_target_cpp_properties(comsupp WITH_EXCEPTIONS)
+
 add_dependencies(comsupp psdk)
index de120e4..7db6f5c 100644 (file)
@@ -1,6 +1,4 @@
 
-set_cpp(WITH_EXCEPTIONS)
-
 include_directories(
     ${REACTOS_SOURCE_DIR}/sdk/lib/crt/include
     ${REACTOS_SOURCE_DIR}/sdk/include/c++)
@@ -21,4 +19,5 @@ elseif(ARCH STREQUAL "arm")
 endif()
 
 add_library(cpprt ${SOURCE} ${cpprt_asm})
+set_target_cpp_properties(cpprt WITH_EXCEPTIONS)
 add_dependencies(cpprt xdk)
index b7f8fac..5825f84 100644 (file)
@@ -1,4 +1,3 @@
 
-set_cpp()
 add_library(stdunk cunknown.cpp)
 add_dependencies(stdunk xdk)