[CMAKE] Get rid of the set_cpp macro

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
This commit is contained in:
Jérôme Gardou 2020-09-18 09:34:18 +02:00 committed by Jérôme Gardou
parent 980ce77316
commit d6ea8659c8
69 changed files with 193 additions and 259 deletions

View 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")

View 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)

View 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)

View 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)

View file

@ -1,4 +1,3 @@
set_cpp()
add_library(stdunk cunknown.cpp)
add_dependencies(stdunk xdk)