mirror of
https://github.com/reactos/reactos.git
synced 2024-09-11 21:34:09 +00:00
160 lines
5.5 KiB
CMake
160 lines
5.5 KiB
CMake
|
|
|
|
if(NOT CMAKE_CROSSCOMPILING)
|
|
|
|
add_definitions(-fshort-wchar)
|
|
|
|
|
|
else()
|
|
|
|
# Linking
|
|
link_directories("${REACTOS_SOURCE_DIR}/importlibs" ${REACTOS_BINARY_DIR}/lib/3rdparty/mingw)
|
|
set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
|
|
set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
|
|
set(CMAKE_EXE_LINKER_FLAGS "-nodefaultlibs -nostdlib -Wl,--enable-auto-image-base -Wl,--kill-at")
|
|
# -Wl,-T,${REACTOS_SOURCE_DIR}/global.lds
|
|
|
|
# Compiler Core
|
|
add_definitions(-pipe -fms-extensions)
|
|
|
|
set(CMAKE_C_CREATE_SHARED_LIBRARY "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_C_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
|
|
|
|
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>")
|
|
|
|
# Debugging (Note: DWARF-4 on 4.5.1 when we ship)
|
|
#add_definitions(-gdwarf-2 -g2 -femit-struct-debug-detailed=none -feliminate-unused-debug-types)
|
|
|
|
# Tuning
|
|
add_definitions(-march=pentium -mtune=i686)
|
|
|
|
# Warnings
|
|
add_definitions(-Wall -Wno-char-subscripts -Wpointer-arith -Wno-multichar -Wno-error=uninitialized -Wno-unused-value -Winvalid-pch)
|
|
|
|
# Optimizations
|
|
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()
|
|
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 "-Wl,--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})
|
|
endmacro()
|
|
|
|
macro(set_image_base MODULE IMAGE_BASE)
|
|
set(NEW_LINKER_FLAGS "-Wl,--image-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})
|
|
endmacro()
|
|
|
|
macro(add_importlibs MODULE)
|
|
foreach(LIB ${ARGN})
|
|
target_link_libraries(${MODULE} ${LIB}.dll.a)
|
|
endforeach()
|
|
endmacro()
|
|
|
|
macro(set_module_type MODULE TYPE)
|
|
|
|
add_dependencies(${MODULE} psdk buildno_header)
|
|
|
|
if(${IS_CPP})
|
|
target_link_libraries(${MODULE} stlport -lsupc++ -lgcc)
|
|
endif()
|
|
|
|
if(${TYPE} MATCHES nativecui)
|
|
set_subsystem(${MODULE} native)
|
|
set_entrypoint(${MODULE} NtProcessStartup@4)
|
|
endif()
|
|
if(${TYPE} MATCHES win32gui)
|
|
set_subsystem(${MODULE} windows)
|
|
set_entrypoint(${MODULE} WinMainCRTStartup)
|
|
if(NOT IS_UNICODE)
|
|
target_link_libraries(${MODULE} mingw_main)
|
|
else()
|
|
target_link_libraries(${MODULE} mingw_wmain)
|
|
endif(NOT IS_UNICODE)
|
|
target_link_libraries(${MODULE} mingw_common)
|
|
endif()
|
|
if(${TYPE} MATCHES win32cui)
|
|
set_subsystem(${MODULE} console)
|
|
set_entrypoint(${MODULE} mainCRTStartup)
|
|
if(NOT IS_UNICODE)
|
|
target_link_libraries(${MODULE} mingw_main)
|
|
else()
|
|
target_link_libraries(${MODULE} mingw_wmain)
|
|
endif(NOT IS_UNICODE)
|
|
target_link_libraries(${MODULE} mingw_common)
|
|
endif()
|
|
if(${TYPE} MATCHES win32dll)
|
|
set_entrypoint(${MODULE} DllMain@12)
|
|
if(DEFINED baseaddress_${MODULE})
|
|
set_image_base(${MODULE} ${baseaddress_${MODULE}})
|
|
else()
|
|
message(WARNING "${MODULE} has no base address")
|
|
endif()
|
|
endif()
|
|
if(${TYPE} MATCHES win32ocx)
|
|
set_entrypoint(${MODULE} DllMain@12)
|
|
set_target_properties(${MODULE} PROPERTIES SUFFIX ".ocx")
|
|
endif()
|
|
if(${TYPE} MATCHES cpl)
|
|
set_entrypoint(${MODULE} DllMain@12)
|
|
set_target_properties(${MODULE} PROPERTIES SUFFIX ".cpl")
|
|
endif()
|
|
if(${TYPE} MATCHES kernelmodedriver)
|
|
set_target_properties(${MODULE} PROPERTIES LINK_FLAGS "-Wl,--exclude-all-symbols" SUFFIX ".sys")
|
|
set_entrypoint(${MODULE} DriverEntry@8)
|
|
set_subsystem(${MODULE} native)
|
|
set_image_base(${MODULE} 0x00010000)
|
|
add_dependencies(${MODULE} bugcodes)
|
|
endif()
|
|
endmacro()
|
|
|
|
macro(set_unicode)
|
|
add_definitions(-DUNICODE -D_UNICODE)
|
|
set(IS_UNICODE 1)
|
|
endmacro()
|
|
|
|
# Workaround lack of mingw RC support in cmake
|
|
macro(set_rc_compiler)
|
|
get_directory_property(defines COMPILE_DEFINITIONS)
|
|
get_directory_property(includes INCLUDE_DIRECTORIES)
|
|
|
|
foreach(arg ${defines})
|
|
set(result_defs "${result_defs} -D${arg}")
|
|
endforeach(arg ${defines})
|
|
|
|
foreach(arg ${includes})
|
|
set(result_incs "-I${arg} ${result_incs}")
|
|
endforeach(arg ${includes})
|
|
|
|
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> ${result_defs} ${result_incs} -i <SOURCE> -O coff -o <OBJECT>")
|
|
endmacro()
|
|
|
|
#idl files support
|
|
set(IDL_COMPILER native-widl)
|
|
set(IDL_FLAGS -m32 --win32)
|
|
set(IDL_HEADER_ARG -h -H) #.h
|
|
set(IDL_TYPELIB_ARG -t -T) #.tlb
|
|
set(IDL_SERVER_ARG -s -S) #.c for server library
|
|
set(IDL_CLIENT_ARG -c -C) #.c for stub client library
|
|
|
|
endif() |