2010-10-07 22:09:31 +00:00
|
|
|
|
|
|
|
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>")
|
2010-11-05 23:17:29 +00:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "-nodefaultlibs -nostdlib -Wl,--enable-auto-image-base -Wl,--kill-at -Wl,--disable-auto-import")
|
2010-10-07 22:09:31 +00:00
|
|
|
# -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>")
|
2010-11-05 23:17:29 +00:00
|
|
|
set(CMAKE_CXX_CREATE_SHARED_LIBRARY "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
|
2010-10-07 22:09:31 +00:00
|
|
|
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
|
2010-11-08 12:24:33 +00:00
|
|
|
macro(add_linkerflag MODULE _flag)
|
|
|
|
set(NEW_LINKER_FLAGS ${_flag})
|
2010-10-07 22:09:31 +00:00
|
|
|
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()
|
|
|
|
|
2010-11-08 12:24:33 +00:00
|
|
|
macro(set_entrypoint MODULE ENTRYPOINT)
|
|
|
|
if(${ENTRYPOINT} STREQUAL "0")
|
|
|
|
add_linkerflag(${MODULE} "-Wl,-entry,0")
|
|
|
|
else()
|
|
|
|
add_linkerflag(${MODULE} "-Wl,-entry,_${ENTRYPOINT}")
|
2010-10-07 22:09:31 +00:00
|
|
|
endif()
|
2010-11-08 12:24:33 +00:00
|
|
|
endmacro()
|
|
|
|
|
|
|
|
macro(set_subsystem MODULE SUBSYSTEM)
|
|
|
|
add_linkerflag(${MODULE} "-Wl,--subsystem,${SUBSYSTEM}")
|
2010-10-07 22:09:31 +00:00
|
|
|
endmacro()
|
|
|
|
|
2010-10-24 12:44:36 +00:00
|
|
|
macro(set_image_base MODULE IMAGE_BASE)
|
2010-11-12 23:52:40 +00:00
|
|
|
add_linkerflag(${MODULE} "-Wl,--image-base,${IMAGE_BASE}")
|
2010-10-24 12:44:36 +00:00
|
|
|
endmacro()
|
|
|
|
|
2010-10-07 22:09:31 +00:00
|
|
|
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)
|
2010-10-14 11:03:20 +00:00
|
|
|
|
|
|
|
if(${IS_CPP})
|
|
|
|
target_link_libraries(${MODULE} stlport -lsupc++ -lgcc)
|
|
|
|
endif()
|
|
|
|
|
2010-10-07 22:09:31 +00:00
|
|
|
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)
|
2010-10-08 21:02:11 +00:00
|
|
|
target_link_libraries(${MODULE} mingw_common)
|
2010-10-07 22:09:31 +00:00
|
|
|
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)
|
2010-10-08 21:02:11 +00:00
|
|
|
target_link_libraries(${MODULE} mingw_common)
|
2010-10-07 22:09:31 +00:00
|
|
|
endif()
|
|
|
|
if(${TYPE} MATCHES win32dll)
|
|
|
|
set_entrypoint(${MODULE} DllMain@12)
|
2010-10-27 14:00:51 +00:00
|
|
|
if(DEFINED baseaddress_${MODULE})
|
|
|
|
set_image_base(${MODULE} ${baseaddress_${MODULE}})
|
|
|
|
else()
|
2010-10-27 22:25:35 +00:00
|
|
|
message(STATUS "${MODULE} has no base address")
|
2010-10-27 14:00:51 +00:00
|
|
|
endif()
|
2010-10-07 22:09:31 +00:00
|
|
|
endif()
|
|
|
|
if(${TYPE} MATCHES win32ocx)
|
|
|
|
set_entrypoint(${MODULE} DllMain@12)
|
|
|
|
set_target_properties(${MODULE} PROPERTIES SUFFIX ".ocx")
|
|
|
|
endif()
|
2010-10-13 12:11:50 +00:00
|
|
|
if(${TYPE} MATCHES cpl)
|
|
|
|
set_entrypoint(${MODULE} DllMain@12)
|
|
|
|
set_target_properties(${MODULE} PROPERTIES SUFFIX ".cpl")
|
|
|
|
endif()
|
2010-10-14 11:03:20 +00:00
|
|
|
if(${TYPE} MATCHES kernelmodedriver)
|
2010-10-24 12:44:36 +00:00
|
|
|
set_target_properties(${MODULE} PROPERTIES LINK_FLAGS "-Wl,--exclude-all-symbols" SUFFIX ".sys")
|
2010-10-14 11:03:20 +00:00
|
|
|
set_entrypoint(${MODULE} DriverEntry@8)
|
|
|
|
set_subsystem(${MODULE} native)
|
2010-10-24 12:44:36 +00:00
|
|
|
set_image_base(${MODULE} 0x00010000)
|
2010-10-14 11:03:20 +00:00
|
|
|
add_dependencies(${MODULE} bugcodes)
|
|
|
|
endif()
|
2010-10-07 22:09:31 +00:00
|
|
|
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()
|
|
|
|
|
2010-10-26 17:42:02 +00:00
|
|
|
#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
|
|
|
|
|
2010-11-02 17:25:36 +00:00
|
|
|
macro(add_importlib_target _def_file)
|
2010-10-31 17:31:05 +00:00
|
|
|
# empty for now, while import libs are shipped
|
|
|
|
endmacro()
|
|
|
|
|
2010-11-10 12:33:24 +00:00
|
|
|
MACRO(spec2def _dllname _spec_file)
|
|
|
|
get_filename_component(_file ${_spec_file} NAME_WE)
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file}.def
|
|
|
|
COMMAND native-winebuild -o ${CMAKE_CURRENT_BINARY_DIR}/${_file}.def --def -E ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file} --filename ${_dllname}
|
|
|
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file})
|
|
|
|
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${_file}.def
|
|
|
|
PROPERTIES GENERATED TRUE EXTERNAL_OBJECT TRUE)
|
|
|
|
ENDMACRO(spec2def _dllname _spec_file)
|
|
|
|
|
2010-11-06 11:31:38 +00:00
|
|
|
macro(pdef2def _pdef_file)
|
|
|
|
get_filename_component(_file ${_pdef_file} NAME_WE)
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file}.def
|
|
|
|
COMMAND ${MINGW_PREFIX}cpp -o ${CMAKE_CURRENT_BINARY_DIR}/${_file}.def -P -E ${CMAKE_CURRENT_SOURCE_DIR}/${_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)
|
2010-11-08 12:24:33 +00:00
|
|
|
add_custom_target(
|
|
|
|
${_file}_def
|
|
|
|
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_file}.def)
|
2010-11-06 11:31:38 +00:00
|
|
|
endmacro(pdef2def _pdef_file)
|
|
|
|
|
2010-11-08 12:24:33 +00:00
|
|
|
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")
|
2010-11-08 19:01:52 +00:00
|
|
|
add_dependencies(${_module} ${_file}_def)
|
2010-11-08 12:24:33 +00:00
|
|
|
endmacro()
|
|
|
|
|
2010-11-01 17:24:32 +00:00
|
|
|
#pseh lib, needed with mingw
|
|
|
|
set(PSEH_LIB "pseh")
|
|
|
|
|
2010-10-31 17:31:05 +00:00
|
|
|
endif()
|