mirror of
https://github.com/reactos/reactos.git
synced 2025-01-10 16:18:16 +00:00
[CMAKE]
- add new macro add_linkerflag to avoid code duplication - add new macro set_pdef_file, replacing the use of pdef2def, which is neccessary to resolve issues with MSVC. cmake doesn't handle def files as source files very well, when they are not in the current source directory. svn path=/branches/cmake-bringup/; revision=49524
This commit is contained in:
parent
c3774adb66
commit
c4f1145fca
2 changed files with 49 additions and 32 deletions
32
gcc.cmake
32
gcc.cmake
|
@ -32,12 +32,8 @@ add_definitions(-Wall -Wno-char-subscripts -Wpointer-arith -Wno-multichar -Wno-e
|
|||
add_definitions(-Os -fno-strict-aliasing -ftracer -momit-leaf-frame-pointer -mpreferred-stack-boundary=2 -fno-set-stack-executable -fno-optimize-sibling-calls)
|
||||
|
||||
# Macros
|
||||
macro(set_entrypoint MODULE ENTRYPOINT)
|
||||
if(${ENTRYPOINT} STREQUAL "0")
|
||||
set(NEW_LINKER_FLAGS "-Wl,-entry,0")
|
||||
else()
|
||||
set(NEW_LINKER_FLAGS "-Wl,-entry,_${ENTRYPOINT}")
|
||||
endif()
|
||||
macro(add_linkerflag MODULE _flag)
|
||||
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}")
|
||||
|
@ -45,13 +41,16 @@ macro(set_entrypoint MODULE ENTRYPOINT)
|
|||
set_target_properties(${MODULE} PROPERTIES LINK_FLAGS ${NEW_LINKER_FLAGS})
|
||||
endmacro()
|
||||
|
||||
macro(set_subsystem MODULE SUBSYSTEM)
|
||||
set(NEW_LINKER_FLAGS "-Wl,--subsystem,${SUBSYSTEM}")
|
||||
get_target_property(LINKER_FLAGS ${MODULE} LINK_FLAGS)
|
||||
if(LINKER_FLAGS)
|
||||
set(NEW_LINKER_FLAGS "${LINKER_FLAGS} ${NEW_LINKER_FLAGS}")
|
||||
macro(set_entrypoint MODULE ENTRYPOINT)
|
||||
if(${ENTRYPOINT} STREQUAL "0")
|
||||
add_linkerflag(${MODULE} "-Wl,-entry,0")
|
||||
else()
|
||||
add_linkerflag(${MODULE} "-Wl,-entry,_${ENTRYPOINT}")
|
||||
endif()
|
||||
set_target_properties(${MODULE} PROPERTIES LINK_FLAGS ${NEW_LINKER_FLAGS})
|
||||
endmacro()
|
||||
|
||||
macro(set_subsystem MODULE SUBSYSTEM)
|
||||
add_linkerflag(${MODULE} "-Wl,--subsystem,${SUBSYSTEM}")
|
||||
endmacro()
|
||||
|
||||
macro(set_image_base MODULE IMAGE_BASE)
|
||||
|
@ -167,8 +166,17 @@ macro(pdef2def _pdef_file)
|
|||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_pdef_file})
|
||||
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${_file}.def
|
||||
PROPERTIES GENERATED TRUE EXTERNAL_OBJECT TRUE)
|
||||
add_custom_target(
|
||||
${_file}_def
|
||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_file}.def)
|
||||
endmacro(pdef2def _pdef_file)
|
||||
|
||||
macro(set_pdef_file _module _pdef_file)
|
||||
pdef2def(${_pdef_file})
|
||||
get_filename_component(_file ${_pdef_file} NAME_WE)
|
||||
target_link_libraries(${_module} "${CMAKE_CURRENT_BINARY_DIR}/${_file}.def")
|
||||
endmacro()
|
||||
|
||||
#pseh lib, needed with mingw
|
||||
set(PSEH_LIB "pseh")
|
||||
|
||||
|
|
49
msc.cmake
49
msc.cmake
|
@ -23,36 +23,29 @@ link_directories("${REACTOS_BINARY_DIR}/importlibs" ${REACTOS_BINARY_DIR}/lib/3r
|
|||
|
||||
set(CMAKE_RC_CREATE_SHARED_LIBRARY "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_C_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
|
||||
|
||||
macro(add_linkerflag MODULE _flag)
|
||||
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})
|
||||
endmacro()
|
||||
|
||||
macro(set_entrypoint MODULE ENTRYPOINT)
|
||||
if(${ENTRYPOINT} STREQUAL "0")
|
||||
set(NEW_LINKER_FLAGS "/ENTRY:0")
|
||||
add_linkerflag(${MODULE} "/ENTRY:0")
|
||||
else()
|
||||
set(NEW_LINKER_FLAGS "/ENTRY:${ENTRYPOINT}")
|
||||
add_linkerflag(${MODULE} "/ENTRY:${ENTRYPOINT}")
|
||||
endif()
|
||||
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})
|
||||
endmacro()
|
||||
|
||||
macro(set_subsystem MODULE SUBSYSTEM)
|
||||
set(NEW_LINKER_FLAGS "/subsystem:${SUBSYSTEM}")
|
||||
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})
|
||||
add_linkerflag(${MODULE} "/subsystem:${SUBSYSTEM}")
|
||||
endmacro()
|
||||
|
||||
macro(set_image_base MODULE IMAGE_BASE)
|
||||
set(NEW_LINKER_FLAGS "/BASE:${IMAGE_BASE}")
|
||||
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})
|
||||
add_linkerflag(${MODULE} "/BASE:${IMAGE_BASE}")
|
||||
endmacro()
|
||||
|
||||
macro(set_module_type MODULE TYPE)
|
||||
|
@ -67,6 +60,7 @@ macro(set_module_type MODULE TYPE)
|
|||
if (${TYPE} MATCHES win32cui)
|
||||
set_subsystem(${MODULE} console)
|
||||
set_entrypoint(${MODULE} mainCRTStartup)
|
||||
target_link_libraries(${MODULE} mingw_common mingw_wmain)
|
||||
endif ()
|
||||
if(${TYPE} MATCHES win32dll)
|
||||
# Need this only because mingw library is broken
|
||||
|
@ -77,6 +71,7 @@ macro(set_module_type MODULE TYPE)
|
|||
message(STATUS "${MODULE} has no base address")
|
||||
endif()
|
||||
target_link_libraries(${MODULE} mingw_common mingw_dllmain)
|
||||
add_importlibs(${MODULE} msvcrt kernel32)
|
||||
endif()
|
||||
|
||||
endmacro()
|
||||
|
@ -122,7 +117,21 @@ macro(add_importlibs MODULE)
|
|||
endmacro()
|
||||
|
||||
macro(pdef2def _pdef_file)
|
||||
# Dummy for now
|
||||
get_filename_component(_file ${_pdef_file} NAME_WE)
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file}.def
|
||||
COMMAND ${CMAKE_C_COMPILER} /EP /c ${CMAKE_CURRENT_SOURCE_DIR}/${_pdef_file} > ${CMAKE_CURRENT_BINARY_DIR}/${_file}.def
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_pdef_file})
|
||||
add_custom_target(
|
||||
${_file}_def
|
||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_file}.def)
|
||||
endmacro(pdef2def _pdef_file)
|
||||
|
||||
macro(set_pdef_file _module _pdef_file)
|
||||
pdef2def(${_pdef_file})
|
||||
get_filename_component(_file ${_pdef_file} NAME_WE)
|
||||
add_linkerflag(${_module} "/DEF:${CMAKE_CURRENT_BINARY_DIR}/${_file}.def")
|
||||
add_dependencies(${_module} ${_file}_def)
|
||||
endmacro()
|
||||
|
||||
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/importlibs)
|
||||
|
|
Loading…
Reference in a new issue