From 427928c2a517694ac6b6f1aa45535664d2c14eef Mon Sep 17 00:00:00 2001 From: Thomas Faber Date: Sat, 3 Sep 2011 18:59:14 +0000 Subject: [PATCH] [CMAKE] - Replace add_linkerflag and add_compiler_flags with their new equivalents add_target_link_flags/add_compile_flags - Remove those now obsolete macros - Use the new set_module_type to get rid of evil hacks for drivers without entry point (wmilib, drmk) svn path=/trunk/; revision=53558 --- reactos/CMakeLists.txt | 2 +- reactos/cmake/compilerflags.cmake | 31 ++----------------- reactos/dll/3rdparty/mesa32/CMakeLists.txt | 2 +- reactos/dll/ntdll/CMakeLists.txt | 2 +- reactos/dll/win32/browseui/CMakeLists.txt | 2 +- reactos/dll/win32/msvcrt/CMakeLists.txt | 2 +- reactos/dll/win32/msvcrt20/CMakeLists.txt | 2 +- reactos/dll/win32/msvcrt40/CMakeLists.txt | 2 +- reactos/dll/win32/msxml3/CMakeLists.txt | 2 +- .../dll/win32/windowscodecs/CMakeLists.txt | 2 +- .../drivers/wdm/audio/drm/drmk/CMakeLists.txt | 12 +------ reactos/drivers/wmi/CMakeLists.txt | 13 +------- reactos/lib/3rdparty/mingw/CMakeLists.txt | 2 +- reactos/lib/newinflib/CMakeLists.txt | 2 +- reactos/lib/sdk/crt/msvcrtex.cmake | 2 +- 15 files changed, 17 insertions(+), 63 deletions(-) diff --git a/reactos/CMakeLists.txt b/reactos/CMakeLists.txt index bd47278112c..f96d1297b1c 100644 --- a/reactos/CMakeLists.txt +++ b/reactos/CMakeLists.txt @@ -52,7 +52,7 @@ if(NOT CMAKE_CROSSCOMPILING) endif() add_definitions(/Dinline=__inline) else() - add_compiler_flags(-fshort-wchar) + add_compile_flags("-fshort-wchar") endif() include_directories(include/host) diff --git a/reactos/cmake/compilerflags.cmake b/reactos/cmake/compilerflags.cmake index 5d3ece6d12f..c5cc19ab3b2 100644 --- a/reactos/cmake/compilerflags.cmake +++ b/reactos/cmake/compilerflags.cmake @@ -24,33 +24,8 @@ function(add_target_property _module _propname) set_property(TARGET ${_module} PROPERTY ${_propname} ${_newvalue}) endfunction() -# -# For backwards compatibility. To be removed soon. -# -function(add_compiler_flags) - set(flags_list "") - # Adds the compiler flag to both CMAKE_C_FLAGS and CMAKE_CXX_FLAGS - foreach(flag ${ARGN}) - set(flags_list "${flags_list} ${flag}") - endforeach() - - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flags_list}" PARENT_SCOPE) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flags_list}" PARENT_SCOPE) -endfunction() - -function(add_linkerflag MODULE _flag) - if (${ARGC} GREATER 2) - message(STATUS "Excess arguments to add_linkerflag! Module ${MODULE}, args ${ARGN}") - endif() - set(NEW_LINKER_FLAGS ${_flag}) - get_target_property(LINKER_FLAGS ${MODULE} LINK_FLAGS) - if(LINKER_FLAGS) - set(NEW_LINKER_FLAGS "${LINKER_FLAGS} ${NEW_LINKER_FLAGS}") - endif() - set_target_properties(${MODULE} PROPERTIES LINK_FLAGS ${NEW_LINKER_FLAGS}) -endfunction() - -# New versions, using add_target_property where appropriate. +# Wrapper functions for the important properties, using add_target_property +# where appropriate. # Note that the functions for string properties take a single string # argument while those for list properties can take a variable number of # arguments, all of which will be added to the list @@ -59,7 +34,7 @@ endfunction() # add_compile_flags("-pedantic -O5") # add_target_link_flags(mymodule "-s --fatal-warnings") # add_target_compile_flags(mymodule "-pedantic -O5") -# add_target_compile_definitions(mymodule WIN32 _WIN32) +# add_target_compile_definitions(mymodule WIN32 _WIN32 INLINE=inline) # add_target_include_directories(mymodule include ../include) function(add_compile_flags _flags) if (${ARGC} GREATER 1) diff --git a/reactos/dll/3rdparty/mesa32/CMakeLists.txt b/reactos/dll/3rdparty/mesa32/CMakeLists.txt index 978f8910bee..32cf70fc86c 100644 --- a/reactos/dll/3rdparty/mesa32/CMakeLists.txt +++ b/reactos/dll/3rdparty/mesa32/CMakeLists.txt @@ -1,6 +1,6 @@ if(NOT MSVC) - add_compiler_flags(-w) + add_compile_flags("-w") endif() add_definitions( diff --git a/reactos/dll/ntdll/CMakeLists.txt b/reactos/dll/ntdll/CMakeLists.txt index 5315a55e487..65e543bf66d 100644 --- a/reactos/dll/ntdll/CMakeLists.txt +++ b/reactos/dll/ntdll/CMakeLists.txt @@ -39,7 +39,7 @@ add_library(ntdll SHARED ${SOURCE}) set_module_type(ntdll win32dll ENTRYPOINT 0) if(MSVC) - add_linkerflag(ntdll /RELEASE) + add_target_link_flags(ntdll "/RELEASE") endif() target_link_libraries(ntdll diff --git a/reactos/dll/win32/browseui/CMakeLists.txt b/reactos/dll/win32/browseui/CMakeLists.txt index 12d9899635b..9748f175395 100644 --- a/reactos/dll/win32/browseui/CMakeLists.txt +++ b/reactos/dll/win32/browseui/CMakeLists.txt @@ -7,7 +7,7 @@ add_definitions( -DROS_Headers) if (MSVC) - add_compiler_flags(/EHa-) + add_compile_flags("/EHa-") endif() remove_definitions(-D_WIN32_WINNT=0x502) diff --git a/reactos/dll/win32/msvcrt/CMakeLists.txt b/reactos/dll/win32/msvcrt/CMakeLists.txt index 9a3a1f0f865..6a5987b7838 100644 --- a/reactos/dll/win32/msvcrt/CMakeLists.txt +++ b/reactos/dll/win32/msvcrt/CMakeLists.txt @@ -31,7 +31,7 @@ target_link_libraries(msvcrt crt wine ${PSEH_LIB}) if(MSVC) # export of deleting destructor "name" - add_linkerflag(msvcrt "/ignore:4102") + add_target_link_flags(msvcrt "/ignore:4102") endif() add_importlibs(msvcrt kernel32 ntdll) diff --git a/reactos/dll/win32/msvcrt20/CMakeLists.txt b/reactos/dll/win32/msvcrt20/CMakeLists.txt index 2de205cee95..dc114a5c466 100644 --- a/reactos/dll/win32/msvcrt20/CMakeLists.txt +++ b/reactos/dll/win32/msvcrt20/CMakeLists.txt @@ -28,7 +28,7 @@ target_link_libraries(msvcrt20 crt wine ${PSEH_LIB}) if(MSVC) # export of deleting destructor "name" - add_linkerflag(msvcrt20 "/ignore:4102") + add_target_link_flags(msvcrt20 "/ignore:4102") endif() add_importlibs(msvcrt20 kernel32 ntdll) diff --git a/reactos/dll/win32/msvcrt40/CMakeLists.txt b/reactos/dll/win32/msvcrt40/CMakeLists.txt index cd2624771a2..7b4e548ed7c 100644 --- a/reactos/dll/win32/msvcrt40/CMakeLists.txt +++ b/reactos/dll/win32/msvcrt40/CMakeLists.txt @@ -29,7 +29,7 @@ target_link_libraries(msvcrt40 crt wine ${PSEH_LIB}) if(MSVC) # export of deleting destructor "name" - add_linkerflag(msvcrt40 "/ignore:4102") + add_target_link_flags(msvcrt40 "/ignore:4102") endif() add_importlibs(msvcrt40 kernel32 ntdll) diff --git a/reactos/dll/win32/msxml3/CMakeLists.txt b/reactos/dll/win32/msxml3/CMakeLists.txt index bfa9239cd82..4b8102ae3cc 100644 --- a/reactos/dll/win32/msxml3/CMakeLists.txt +++ b/reactos/dll/win32/msxml3/CMakeLists.txt @@ -11,7 +11,7 @@ add_definitions( -DLIBXML_STATIC) if(MSVC) - add_compiler_flags(/FIwine/typeof.h /FImsvc.h) + add_compile_flags("/FIwine/typeof.h /FImsvc.h") endif(MSVC) include_directories(${REACTOS_SOURCE_DIR}/include/reactos/wine) diff --git a/reactos/dll/win32/windowscodecs/CMakeLists.txt b/reactos/dll/win32/windowscodecs/CMakeLists.txt index d99a32ce498..a0165d37923 100644 --- a/reactos/dll/win32/windowscodecs/CMakeLists.txt +++ b/reactos/dll/win32/windowscodecs/CMakeLists.txt @@ -13,7 +13,7 @@ include_directories( set_rc_compiler() if(MSVC) - add_compiler_flags(/FItypeof.h) + add_compile_flags("/FItypeof.h") endif() spec2def(windowscodecs.dll windowscodecs.spec) diff --git a/reactos/drivers/wdm/audio/drm/drmk/CMakeLists.txt b/reactos/drivers/wdm/audio/drm/drmk/CMakeLists.txt index eb70b994869..5026ba75cc5 100644 --- a/reactos/drivers/wdm/audio/drm/drmk/CMakeLists.txt +++ b/reactos/drivers/wdm/audio/drm/drmk/CMakeLists.txt @@ -10,18 +10,8 @@ list(APPEND SOURCE add_library(drmk SHARED ${SOURCE}) -if(NOT MSVC) - set_module_type(drmk kernelmodedriver) -else() - set_target_properties(drmk PROPERTIES SUFFIX ".sys") - set_subsystem(drmk native) - set_image_base(drmk 0x00010000) - add_linkerflag(drmk "/DRIVER") - add_dependencies(drmk bugcodes) - add_dependencies(drmk psdk) -endif() +set_module_type(drmk kernelmodedriver ENTRYPOINT 0) -set_entrypoint(drmk 0) add_importlibs(drmk ntoskrnl) add_importlib_target(drmk.spec) add_cd_file(TARGET drmk DESTINATION reactos/system32/drivers FOR all) diff --git a/reactos/drivers/wmi/CMakeLists.txt b/reactos/drivers/wmi/CMakeLists.txt index c00a650c931..c67295004ca 100644 --- a/reactos/drivers/wmi/CMakeLists.txt +++ b/reactos/drivers/wmi/CMakeLists.txt @@ -8,19 +8,8 @@ list(APPEND SOURCE add_library(wmilib SHARED ${SOURCE}) -if(NOT MSVC) - set_module_type(wmilib kernelmodedriver) -else() - set_target_properties(wmilib PROPERTIES SUFFIX ".sys") - set_subsystem(wmilib native) - set_image_base(wmilib 0x00010000) - add_linkerflag(wmilib "/DRIVER") - add_dependencies(wmilib bugcodes) - add_dependencies(wmilib psdk) -endif() +set_module_type(wmilib kernelmodedriver ENTRYPOINT 0) -set_entrypoint(wmilib 0) -set_target_properties(wmilib PROPERTIES SUFFIX ".sys") add_importlibs(wmilib ntoskrnl) add_importlib_target(wmilib.spec) add_cd_file(TARGET wmilib DESTINATION reactos/system32/drivers FOR all) diff --git a/reactos/lib/3rdparty/mingw/CMakeLists.txt b/reactos/lib/3rdparty/mingw/CMakeLists.txt index cbbca9ca933..eac3dd13379 100644 --- a/reactos/lib/3rdparty/mingw/CMakeLists.txt +++ b/reactos/lib/3rdparty/mingw/CMakeLists.txt @@ -4,7 +4,7 @@ include_directories(${REACTOS_SOURCE_DIR}/include/reactos/mingw-w64) add_definitions(-D_CRTBLD) if(NOT MSVC) - add_definitions(-Wno-main) + add_compile_flags("-Wno-main") endif() list(APPEND MINGW_COMMON_SOURCE diff --git a/reactos/lib/newinflib/CMakeLists.txt b/reactos/lib/newinflib/CMakeLists.txt index 65b092e11fc..7d38008ddb4 100644 --- a/reactos/lib/newinflib/CMakeLists.txt +++ b/reactos/lib/newinflib/CMakeLists.txt @@ -22,7 +22,7 @@ else() add_definitions(-D__NO_CTYPE_INLINES -DINFLIB_HOST) if(NOT MSVC) - add_compiler_flags(-Wpointer-arith -Wwrite-strings) + add_compile_flags("-Wpointer-arith -Wwrite-strings") endif() add_library(inflibhost ${GLOBAL_FILES} ${SOURCE}) target_link_libraries(inflibhost unicode) diff --git a/reactos/lib/sdk/crt/msvcrtex.cmake b/reactos/lib/sdk/crt/msvcrtex.cmake index 9099448f55e..9bc5dd0e47d 100644 --- a/reactos/lib/sdk/crt/msvcrtex.cmake +++ b/reactos/lib/sdk/crt/msvcrtex.cmake @@ -2,7 +2,7 @@ include_directories(include/internal/mingw-w64) if(NOT MSVC) - add_compiler_flags(-Wno-main) + add_compile_flags("-Wno-main") endif() list(APPEND MSVCRTEX_SOURCE