2011-05-16 13:12:07 +00:00
|
|
|
|
2011-09-27 21:21:59 +00:00
|
|
|
# Show a note about ccache build
|
|
|
|
if(CCACHE STREQUAL "ccache")
|
|
|
|
message("-- Enabling ccache build - done")
|
|
|
|
endif()
|
|
|
|
|
2011-05-16 13:12:07 +00:00
|
|
|
# Compiler Core
|
2011-09-03 14:57:27 +00:00
|
|
|
add_compile_flags("-pipe -fms-extensions")
|
2011-05-16 13:12:07 +00:00
|
|
|
|
|
|
|
# Debugging (Note: DWARF-4 on 4.5.1 when we ship)
|
2011-10-08 16:47:57 +00:00
|
|
|
# add_compile_flags("-gdwarf-2 -g2 -femit-struct-debug-detailed=none -feliminate-unused-debug-types")
|
|
|
|
add_compile_flags("-gstabs+")
|
2011-05-16 13:12:07 +00:00
|
|
|
|
2011-09-04 17:32:30 +00:00
|
|
|
# Do not allow warnings
|
|
|
|
add_compile_flags("-Werror")
|
|
|
|
|
2011-09-03 23:05:09 +00:00
|
|
|
# For some reason, cmake sets -fPIC, and we don't want it
|
2011-09-05 12:41:18 +00:00
|
|
|
if(DEFINED CMAKE_SHARED_LIBRARY_ASM_FLAGS)
|
|
|
|
string(REPLACE "-fPIC" "" CMAKE_SHARED_LIBRARY_ASM_FLAGS ${CMAKE_SHARED_LIBRARY_ASM_FLAGS})
|
|
|
|
endif()
|
2011-09-03 23:05:09 +00:00
|
|
|
|
2011-05-16 13:12:07 +00:00
|
|
|
# Tuning
|
|
|
|
if(ARCH MATCHES i386)
|
2011-09-03 14:57:27 +00:00
|
|
|
add_compile_flags("-march=${OARCH} -mtune=${TUNE}")
|
2011-05-16 13:12:07 +00:00
|
|
|
else()
|
2011-09-03 14:57:27 +00:00
|
|
|
add_compile_flags("-march=${OARCH}")
|
2011-05-16 13:12:07 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Warnings
|
2011-09-03 23:05:09 +00:00
|
|
|
add_compile_flags("-Wall -Wno-char-subscripts -Wpointer-arith -Wno-multichar -Wno-error=uninitialized -Wno-unused-value")
|
2011-05-16 13:12:07 +00:00
|
|
|
|
|
|
|
if(ARCH MATCHES amd64)
|
2011-09-03 14:57:27 +00:00
|
|
|
add_compile_flags("-Wno-format")
|
2011-05-16 13:12:07 +00:00
|
|
|
elseif(ARCH MATCHES arm)
|
2011-09-03 14:57:27 +00:00
|
|
|
add_compile_flags("-Wno-attributes")
|
2011-05-16 13:12:07 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Optimizations
|
|
|
|
if(OPTIMIZE STREQUAL "1")
|
2011-09-03 14:57:27 +00:00
|
|
|
add_compile_flags("-Os")
|
2011-05-16 13:12:07 +00:00
|
|
|
elseif(OPTIMIZE STREQUAL "2")
|
2011-09-03 14:57:27 +00:00
|
|
|
add_compile_flags("-Os")
|
2011-05-16 13:12:07 +00:00
|
|
|
elseif(OPTIMIZE STREQUAL "3")
|
2011-09-03 14:57:27 +00:00
|
|
|
add_compile_flags("-O1")
|
2011-05-16 13:12:07 +00:00
|
|
|
elseif(OPTIMIZE STREQUAL "4")
|
2011-09-03 14:57:27 +00:00
|
|
|
add_compile_flags("-O2")
|
2011-05-16 13:12:07 +00:00
|
|
|
elseif(OPTIMIZE STREQUAL "5")
|
2011-09-03 14:57:27 +00:00
|
|
|
add_compile_flags("-O3")
|
2011-05-16 13:12:07 +00:00
|
|
|
endif()
|
|
|
|
|
2011-09-03 14:57:27 +00:00
|
|
|
add_compile_flags("-fno-strict-aliasing")
|
2011-05-16 13:12:07 +00:00
|
|
|
|
|
|
|
if(ARCH MATCHES i386)
|
2011-09-03 14:57:27 +00:00
|
|
|
add_compile_flags("-mpreferred-stack-boundary=2 -fno-set-stack-executable -fno-optimize-sibling-calls -fno-omit-frame-pointer")
|
2011-05-16 13:12:07 +00:00
|
|
|
if(OPTIMIZE STREQUAL "1")
|
2011-09-03 14:57:27 +00:00
|
|
|
add_compile_flags("-ftracer -momit-leaf-frame-pointer")
|
2011-05-16 13:12:07 +00:00
|
|
|
endif()
|
|
|
|
elseif(ARCH MATCHES amd64)
|
2011-09-03 14:57:27 +00:00
|
|
|
add_compile_flags("-mpreferred-stack-boundary=4")
|
2011-05-16 13:12:07 +00:00
|
|
|
if(OPTIMIZE STREQUAL "1")
|
2011-09-03 14:57:27 +00:00
|
|
|
add_compile_flags("-ftracer -momit-leaf-frame-pointer")
|
2011-05-16 13:12:07 +00:00
|
|
|
endif()
|
|
|
|
elseif(ARCH MATCHES arm)
|
|
|
|
if(OPTIMIZE STREQUAL "1")
|
2011-09-03 14:57:27 +00:00
|
|
|
add_compile_flags("-ftracer")
|
2011-05-16 13:12:07 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Other
|
|
|
|
if(ARCH MATCHES amd64)
|
|
|
|
add_definitions(-U_X86_ -UWIN32)
|
|
|
|
elseif(ARCH MATCHES arm)
|
|
|
|
add_definitions(-U_UNICODE -UUNICODE)
|
|
|
|
add_definitions(-D__MSVCRT__) # DUBIOUS
|
|
|
|
endif()
|
|
|
|
|
2012-01-26 19:09:02 +00:00
|
|
|
add_definitions(-D_inline=__inline)
|
|
|
|
|
2011-05-16 13:12:07 +00:00
|
|
|
# alternative arch name
|
|
|
|
if(ARCH MATCHES amd64)
|
|
|
|
set(ARCH2 x86_64)
|
|
|
|
else()
|
|
|
|
set(ARCH2 ${ARCH})
|
|
|
|
endif()
|
|
|
|
|
2011-06-13 10:36:40 +00:00
|
|
|
# Linking
|
|
|
|
if(ARCH MATCHES i386)
|
|
|
|
link_directories(${REACTOS_SOURCE_DIR}/importlibs)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
link_directories(${REACTOS_BINARY_DIR}/lib/sdk/crt)
|
|
|
|
|
2011-10-08 16:47:57 +00:00
|
|
|
get_target_property(RSYM native-rsym IMPORTED_LOCATION_NOCONFIG)
|
2011-06-13 10:36:40 +00:00
|
|
|
|
2011-10-08 16:47:57 +00:00
|
|
|
set(CMAKE_C_LINK_EXECUTABLE
|
|
|
|
"<CMAKE_C_COMPILER> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>"
|
|
|
|
"${RSYM} <TARGET> <TARGET>")
|
|
|
|
|
|
|
|
set(CMAKE_CXX_LINK_EXECUTABLE
|
|
|
|
"<CMAKE_CXX_COMPILER> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>"
|
|
|
|
"${RSYM} <TARGET> <TARGET>")
|
2011-06-13 10:36:40 +00:00
|
|
|
|
2011-09-18 00:57:17 +00:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "-nostdlib -Wl,--enable-auto-image-base,--disable-auto-import,--disable-stdcall-fixup")
|
2011-06-13 10:36:40 +00:00
|
|
|
|
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS_INIT} -Wl,--disable-stdcall-fixup")
|
|
|
|
|
2011-10-08 16:47:57 +00:00
|
|
|
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>"
|
|
|
|
"${RSYM} <TARGET> <TARGET>")
|
|
|
|
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>"
|
|
|
|
"${RSYM} <TARGET> <TARGET>")
|
|
|
|
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>"
|
|
|
|
"${RSYM} <TARGET> <TARGET>")
|
2011-06-13 10:36:40 +00:00
|
|
|
|
2011-09-27 21:21:59 +00:00
|
|
|
SET(CMAKE_C_COMPILE_OBJECT "${CCACHE} <CMAKE_C_COMPILER> <DEFINES> <FLAGS> -o <OBJECT> -c <SOURCE>")
|
|
|
|
SET(CMAKE_CXX_COMPILE_OBJECT "${CCACHE} <CMAKE_CXX_COMPILER> <DEFINES> <FLAGS> -o <OBJECT> -c <SOURCE>")
|
2011-09-03 23:05:09 +00:00
|
|
|
set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> -x assembler-with-cpp -o <OBJECT> -I${REACTOS_SOURCE_DIR}/include/asm -I${REACTOS_BINARY_DIR}/include/asm <FLAGS> <DEFINES> -D__ASM__ -c <SOURCE>")
|
2011-06-13 10:36:40 +00:00
|
|
|
|
|
|
|
#set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> -i <SOURCE> <CMAKE_C_LINK_FLAGS> <DEFINES> -I${REACTOS_SOURCE_DIR}/include/psdk -I${REACTOS_BINARY_DIR}/include/psdk -I${REACTOS_SOURCE_DIR}/include/ -I${REACTOS_SOURCE_DIR}/include/reactos -I${REACTOS_BINARY_DIR}/include/reactos -I${REACTOS_SOURCE_DIR}/include/reactos/wine -I${REACTOS_SOURCE_DIR}/include/crt -I${REACTOS_SOURCE_DIR}/include/crt/mingw32 -O coff -o <OBJECT>")
|
|
|
|
|
|
|
|
# Temporary, until windres issues are fixed
|
|
|
|
get_target_property(WRC native-wrc IMPORTED_LOCATION_NOCONFIG)
|
|
|
|
set(CMAKE_RC_COMPILE_OBJECT
|
|
|
|
"<CMAKE_C_COMPILER> -DRC_INVOKED -D__WIN32__=1 -D__FLAT__=1 <DEFINES> -I${REACTOS_SOURCE_DIR}/include/psdk -I${REACTOS_BINARY_DIR}/include/psdk -I${REACTOS_SOURCE_DIR}/include/ -I${REACTOS_SOURCE_DIR}/include/reactos -I${REACTOS_BINARY_DIR}/include/reactos -I${REACTOS_SOURCE_DIR}/include/reactos/wine -I${REACTOS_SOURCE_DIR}/include/crt -I${REACTOS_SOURCE_DIR}/include/crt/mingw32 -xc -E <SOURCE> -o <OBJECT>"
|
|
|
|
"${WRC} -i <OBJECT> -o <OBJECT>"
|
|
|
|
"<CMAKE_RC_COMPILER> -i <OBJECT> -J res -O coff -o <OBJECT>")
|
2011-05-16 13:12:07 +00:00
|
|
|
|
|
|
|
# Optional 3rd parameter: stdcall stack bytes
|
2011-08-08 11:45:34 +00:00
|
|
|
function(set_entrypoint MODULE ENTRYPOINT)
|
2011-05-16 13:12:07 +00:00
|
|
|
if(${ENTRYPOINT} STREQUAL "0")
|
2011-09-03 14:57:27 +00:00
|
|
|
add_target_link_flags(${MODULE} "-Wl,-entry,0")
|
2011-05-16 13:12:07 +00:00
|
|
|
elseif(ARCH MATCHES i386)
|
|
|
|
set(_entrysymbol _${ENTRYPOINT})
|
2011-10-02 18:59:33 +00:00
|
|
|
if(${ARGC} GREATER 2)
|
2011-05-16 13:12:07 +00:00
|
|
|
set(_entrysymbol ${_entrysymbol}@${ARGV2})
|
|
|
|
endif()
|
2011-09-03 14:57:27 +00:00
|
|
|
add_target_link_flags(${MODULE} "-Wl,-entry,${_entrysymbol}")
|
2011-05-16 13:12:07 +00:00
|
|
|
else()
|
2011-09-03 14:57:27 +00:00
|
|
|
add_target_link_flags(${MODULE} "-Wl,-entry,${ENTRYPOINT}")
|
2011-05-16 13:12:07 +00:00
|
|
|
endif()
|
2011-08-08 11:45:34 +00:00
|
|
|
endfunction()
|
2011-05-16 13:12:07 +00:00
|
|
|
|
2011-08-08 11:45:34 +00:00
|
|
|
function(set_subsystem MODULE SUBSYSTEM)
|
2011-09-03 14:57:27 +00:00
|
|
|
add_target_link_flags(${MODULE} "-Wl,--subsystem,${SUBSYSTEM}")
|
2011-08-08 11:45:34 +00:00
|
|
|
endfunction()
|
2011-05-16 13:12:07 +00:00
|
|
|
|
2011-08-08 11:45:34 +00:00
|
|
|
function(set_image_base MODULE IMAGE_BASE)
|
2011-09-03 14:57:27 +00:00
|
|
|
add_target_link_flags(${MODULE} "-Wl,--image-base,${IMAGE_BASE}")
|
2011-08-08 11:45:34 +00:00
|
|
|
endfunction()
|
2011-05-16 13:12:07 +00:00
|
|
|
|
2011-09-03 17:48:57 +00:00
|
|
|
function(set_module_type_toolchain MODULE TYPE)
|
|
|
|
if(IS_CPP)
|
2011-10-11 18:31:35 +00:00
|
|
|
target_link_libraries(${MODULE} -lstdc++ -lsupc++ -lgcc -lmingwex)
|
2011-05-16 13:12:07 +00:00
|
|
|
endif()
|
|
|
|
|
2011-09-03 17:48:57 +00:00
|
|
|
if(${TYPE} STREQUAL kernelmodedriver)
|
2011-09-18 00:57:17 +00:00
|
|
|
add_target_link_flags(${MODULE} "-Wl,--exclude-all-symbols,-file-alignment=0x1000,-section-alignment=0x1000")
|
2011-05-16 13:12:07 +00:00
|
|
|
endif()
|
2011-08-08 11:45:34 +00:00
|
|
|
endfunction()
|
2011-05-16 13:12:07 +00:00
|
|
|
|
|
|
|
# Workaround lack of mingw RC support in cmake
|
2011-08-08 11:45:34 +00:00
|
|
|
function(set_rc_compiler)
|
2011-05-16 13:12:07 +00:00
|
|
|
get_directory_property(defines COMPILE_DEFINITIONS)
|
|
|
|
get_directory_property(includes INCLUDE_DIRECTORIES)
|
|
|
|
|
|
|
|
foreach(arg ${defines})
|
|
|
|
set(rc_result_defs "${rc_result_defs} -D${arg}")
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
foreach(arg ${includes})
|
|
|
|
set(rc_result_incs "-I${arg} ${rc_result_incs}")
|
|
|
|
endforeach()
|
|
|
|
|
2011-08-08 11:45:34 +00:00
|
|
|
#set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> ${rc_result_defs} ${rc_result_incs} -i <SOURCE> -O coff -o <OBJECT>" PARENT_SCOPE)
|
2011-05-16 13:12:07 +00:00
|
|
|
set(CMAKE_RC_COMPILE_OBJECT
|
|
|
|
"<CMAKE_C_COMPILER> -DRC_INVOKED -D__WIN32__=1 -D__FLAT__=1 ${rc_result_defs} -I${CMAKE_CURRENT_SOURCE_DIR} ${rc_result_incs} -xc -E <SOURCE> -o <OBJECT>"
|
2011-08-21 21:18:59 +00:00
|
|
|
"${WRC} -I${CMAKE_CURRENT_SOURCE_DIR} ${rc_result_incs} -i <OBJECT> -o <OBJECT>"
|
2011-08-08 11:45:34 +00:00
|
|
|
"<CMAKE_RC_COMPILER> -i <OBJECT> -J res -O coff -o <OBJECT>" PARENT_SCOPE)
|
|
|
|
endfunction()
|
2011-05-16 13:12:07 +00:00
|
|
|
|
2011-08-08 11:45:34 +00:00
|
|
|
function(add_delay_importlibs MODULE)
|
2011-06-10 20:44:47 +00:00
|
|
|
foreach(LIB ${ARGN})
|
|
|
|
target_link_libraries(${MODULE} ${CMAKE_BINARY_DIR}/importlibs/lib${LIB}_delayed.a)
|
|
|
|
add_dependencies(${MODULE} lib${LIB}_delayed)
|
|
|
|
endforeach()
|
|
|
|
target_link_libraries(${MODULE} delayimp)
|
2011-08-08 11:45:34 +00:00
|
|
|
endfunction()
|
2011-06-10 20:44:47 +00:00
|
|
|
|
2011-05-16 13:12:07 +00:00
|
|
|
if(NOT ARCH MATCHES i386)
|
|
|
|
set(DECO_OPTION "-@")
|
|
|
|
endif()
|
|
|
|
|
2011-08-08 11:45:34 +00:00
|
|
|
function(add_importlib_target _exports_file)
|
2011-05-16 13:12:07 +00:00
|
|
|
|
2011-06-26 10:21:57 +00:00
|
|
|
get_filename_component(_name ${_exports_file} NAME_WE)
|
|
|
|
get_filename_component(_extension ${_exports_file} EXT)
|
|
|
|
get_target_property(_suffix ${_name} SUFFIX)
|
|
|
|
if(${_suffix} STREQUAL "_suffix-NOTFOUND")
|
|
|
|
get_target_property(_type ${_name} TYPE)
|
|
|
|
if(${_type} MATCHES EXECUTABLE)
|
|
|
|
set(_suffix ".exe")
|
|
|
|
else()
|
|
|
|
set(_suffix ".dll")
|
|
|
|
endif()
|
|
|
|
endif()
|
2011-06-25 18:34:03 +00:00
|
|
|
|
2011-10-02 18:59:33 +00:00
|
|
|
if(${_extension} STREQUAL ".spec")
|
2011-06-26 21:29:55 +00:00
|
|
|
|
|
|
|
# Normal importlib creation
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${CMAKE_BINARY_DIR}/importlibs/lib${_name}.a
|
|
|
|
COMMAND native-spec2def -n=${_name}${_suffix} -a=${ARCH2} -d=${CMAKE_CURRENT_BINARY_DIR}/${_name}_implib.def ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file}
|
2011-09-18 00:57:17 +00:00
|
|
|
COMMAND ${CMAKE_DLLTOOL} --def ${CMAKE_CURRENT_BINARY_DIR}/${_name}_implib.def --kill-at --output-lib=${CMAKE_BINARY_DIR}/importlibs/lib${_name}.a
|
2011-08-05 20:40:40 +00:00
|
|
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file} native-spec2def)
|
2011-06-26 21:29:55 +00:00
|
|
|
|
|
|
|
# Delayed importlib creation
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${CMAKE_BINARY_DIR}/importlibs/lib${_name}_delayed.a
|
|
|
|
COMMAND native-spec2def -n=${_name}${_suffix} -a=${ARCH2} -d=${CMAKE_CURRENT_BINARY_DIR}/${_name}_delayed_implib.def ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file}
|
2011-09-18 00:57:17 +00:00
|
|
|
COMMAND ${CMAKE_DLLTOOL} --def ${CMAKE_CURRENT_BINARY_DIR}/${_name}_delayed_implib.def --kill-at --output-delaylib ${CMAKE_BINARY_DIR}/importlibs/lib${_name}_delayed.a
|
2011-08-05 20:40:40 +00:00
|
|
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file} native-spec2def)
|
2011-06-26 21:29:55 +00:00
|
|
|
|
|
|
|
elseif(${_extension} STREQUAL ".def")
|
2011-06-26 10:21:57 +00:00
|
|
|
message("Use of def files for import libs is deprecated: ${_exports_file}")
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${CMAKE_BINARY_DIR}/importlibs/lib${_name}.a
|
2011-09-18 00:57:17 +00:00
|
|
|
COMMAND ${CMAKE_DLLTOOL} --def ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file} --kill-at --output-lib=${CMAKE_BINARY_DIR}/importlibs/lib${_name}.a
|
2011-06-26 10:21:57 +00:00
|
|
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file})
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${CMAKE_BINARY_DIR}/importlibs/lib${_name}_delayed.a
|
2011-09-18 00:57:17 +00:00
|
|
|
COMMAND ${CMAKE_DLLTOOL} --def ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file} --kill-at --output-delaylib ${CMAKE_BINARY_DIR}/importlibs/lib${_name}_delayed.a
|
2011-06-26 10:21:57 +00:00
|
|
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file})
|
2011-06-26 21:29:55 +00:00
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Unsupported exports file extension: ${_extension}")
|
2011-06-26 10:21:57 +00:00
|
|
|
endif()
|
2011-06-26 21:29:55 +00:00
|
|
|
|
|
|
|
# Normal importlib target
|
|
|
|
add_custom_target(
|
|
|
|
lib${_name}
|
|
|
|
DEPENDS ${CMAKE_BINARY_DIR}/importlibs/lib${_name}.a)
|
|
|
|
# Delayed importlib target
|
|
|
|
add_custom_target(
|
|
|
|
lib${_name}_delayed
|
|
|
|
DEPENDS ${CMAKE_BINARY_DIR}/importlibs/lib${_name}_delayed.a)
|
|
|
|
|
2011-08-08 11:45:34 +00:00
|
|
|
endfunction()
|
2011-05-16 13:12:07 +00:00
|
|
|
|
2011-08-08 11:45:34 +00:00
|
|
|
function(spec2def _dllname _spec_file)
|
2011-08-15 15:36:25 +00:00
|
|
|
|
|
|
|
if(${ARGC} GREATER 2)
|
|
|
|
set(_file ${ARGV2})
|
|
|
|
else()
|
|
|
|
get_filename_component(_file ${_spec_file} NAME_WE)
|
|
|
|
endif()
|
|
|
|
|
2011-05-16 13:12:07 +00:00
|
|
|
add_custom_command(
|
2011-06-26 21:29:55 +00:00
|
|
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file}.def ${CMAKE_CURRENT_BINARY_DIR}/${_file}_stubs.c
|
|
|
|
COMMAND native-spec2def -n=${_dllname} --kill-at -a=${ARCH2} -d=${CMAKE_CURRENT_BINARY_DIR}/${_file}.def -s=${CMAKE_CURRENT_BINARY_DIR}/${_file}_stubs.c ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file}
|
2011-08-05 20:40:40 +00:00
|
|
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file} native-spec2def)
|
2011-05-16 13:12:07 +00:00
|
|
|
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${_file}.def
|
2011-06-26 21:29:55 +00:00
|
|
|
PROPERTIES GENERATED TRUE EXTERNAL_OBJECT TRUE)
|
|
|
|
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${_file}_stubs.c PROPERTIES GENERATED TRUE)
|
2011-08-08 11:45:34 +00:00
|
|
|
endfunction()
|
2011-05-16 13:12:07 +00:00
|
|
|
|
2011-10-03 19:09:26 +00:00
|
|
|
macro(macro_mc FLAG FILE)
|
|
|
|
set(COMMAND_MC ${CMAKE_MC_COMPILER} ${FLAG} -b ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}.mc -r ${REACTOS_BINARY_DIR}/include/reactos -h ${REACTOS_BINARY_DIR}/include/reactos)
|
2011-05-16 13:12:07 +00:00
|
|
|
endmacro()
|
|
|
|
|
|
|
|
#pseh lib, needed with mingw
|
|
|
|
set(PSEH_LIB "pseh")
|
2011-06-02 12:18:22 +00:00
|
|
|
|
|
|
|
# Macros
|
2011-07-25 19:05:00 +00:00
|
|
|
if(PCH)
|
|
|
|
macro(_PCH_GET_COMPILE_FLAGS _target_name _out_compile_flags _header_filename)
|
|
|
|
# Add the precompiled header to the build
|
|
|
|
get_filename_component(_FILE ${_header_filename} NAME)
|
|
|
|
set(_gch_filename "${_FILE}.gch")
|
|
|
|
list(APPEND ${_out_compile_flags} -c ${_header_filename} -o ${_gch_filename})
|
|
|
|
|
|
|
|
# This gets us our includes
|
|
|
|
get_directory_property(DIRINC INCLUDE_DIRECTORIES)
|
|
|
|
foreach(item ${DIRINC})
|
|
|
|
list(APPEND ${_out_compile_flags} -I${item})
|
|
|
|
endforeach()
|
2011-06-02 12:18:22 +00:00
|
|
|
|
2011-07-25 19:05:00 +00:00
|
|
|
# This our definitions
|
|
|
|
get_directory_property(_compiler_flags DEFINITIONS)
|
|
|
|
list(APPEND ${_out_compile_flags} ${_compiler_flags})
|
2011-06-02 12:18:22 +00:00
|
|
|
|
2011-07-25 19:05:00 +00:00
|
|
|
# This gets any specific definitions that were added with set-target-property
|
|
|
|
get_target_property(_target_defs ${_target_name} COMPILE_DEFINITIONS)
|
2011-10-02 18:59:33 +00:00
|
|
|
if(_target_defs)
|
2011-07-25 19:05:00 +00:00
|
|
|
foreach(item ${_target_defs})
|
|
|
|
list(APPEND ${_out_compile_flags} -D${item})
|
|
|
|
endforeach()
|
|
|
|
endif()
|
2011-06-07 23:22:38 +00:00
|
|
|
|
2011-07-25 19:05:00 +00:00
|
|
|
if(IS_CPP)
|
|
|
|
list(APPEND ${_out_compile_flags} ${CMAKE_CXX_FLAGS})
|
|
|
|
else()
|
|
|
|
list(APPEND ${_out_compile_flags} ${CMAKE_C_FLAGS})
|
|
|
|
endif()
|
2011-06-02 12:18:22 +00:00
|
|
|
|
2011-07-25 19:05:00 +00:00
|
|
|
separate_arguments(${_out_compile_flags})
|
|
|
|
endmacro()
|
2011-06-26 21:29:55 +00:00
|
|
|
|
2011-07-25 19:05:00 +00:00
|
|
|
macro(add_pch _target_name _FILE)
|
|
|
|
set(_header_filename ${CMAKE_CURRENT_SOURCE_DIR}/${_FILE})
|
|
|
|
get_filename_component(_basename ${_FILE} NAME)
|
|
|
|
set(_gch_filename ${_basename}.gch)
|
|
|
|
_PCH_GET_COMPILE_FLAGS(${_target_name} _args ${_header_filename})
|
|
|
|
|
|
|
|
if(IS_CPP)
|
|
|
|
set(__lang CXX)
|
2011-09-27 21:21:59 +00:00
|
|
|
set(__compiler ${CCACHE} ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1})
|
2011-07-25 19:05:00 +00:00
|
|
|
else()
|
|
|
|
set(__lang C)
|
2011-09-27 21:21:59 +00:00
|
|
|
set(__compiler ${CCACHE} ${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1})
|
2011-07-25 19:05:00 +00:00
|
|
|
endif()
|
|
|
|
|
2011-08-07 11:13:45 +00:00
|
|
|
add_custom_command(OUTPUT ${_gch_filename}
|
|
|
|
COMMAND ${__compiler} ${_args}
|
|
|
|
IMPLICIT_DEPENDS ${__lang} ${_header_filename}
|
|
|
|
DEPENDS ${_header_filename} ${ARGN})
|
2011-07-25 19:05:00 +00:00
|
|
|
get_target_property(_src_files ${_target_name} SOURCES)
|
2011-09-03 23:05:09 +00:00
|
|
|
add_target_compile_flags(${_target_name} "-fpch-preprocess -Winvalid-pch -Wno-error=invalid-pch")
|
2011-09-04 18:41:04 +00:00
|
|
|
foreach(_item in ${_src_files})
|
|
|
|
get_source_file_property(__src_lang ${_item} LANGUAGE)
|
|
|
|
if(__src_lang STREQUAL __lang)
|
|
|
|
set_source_files_properties(${_item} PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_gch_filename})
|
|
|
|
endif()
|
|
|
|
endforeach()
|
2011-09-03 14:57:27 +00:00
|
|
|
#set dependency checking : depends on precompiled header only which already depends on deeper header
|
2011-07-25 19:05:00 +00:00
|
|
|
set_target_properties(${_target_name} PROPERTIES IMPLICIT_DEPENDS_INCLUDE_TRANSFORM "\"${_basename}\"=;<${_basename}>=")
|
|
|
|
endmacro()
|
|
|
|
else()
|
|
|
|
macro(add_pch _target_name _FILE)
|
|
|
|
endmacro()
|
|
|
|
endif()
|
2011-06-07 23:22:38 +00:00
|
|
|
|
2011-08-08 11:45:34 +00:00
|
|
|
function(CreateBootSectorTarget _target_name _asm_file _object_file _base_address)
|
2011-06-07 23:22:38 +00:00
|
|
|
get_filename_component(OBJECT_PATH ${_object_file} PATH)
|
|
|
|
get_filename_component(OBJECT_NAME ${_object_file} NAME)
|
|
|
|
file(MAKE_DIRECTORY ${OBJECT_PATH})
|
|
|
|
get_directory_property(defines COMPILE_DEFINITIONS)
|
|
|
|
get_directory_property(includes INCLUDE_DIRECTORIES)
|
|
|
|
|
|
|
|
foreach(arg ${defines})
|
|
|
|
set(result_defs ${result_defs} -D${arg})
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
foreach(arg ${includes})
|
|
|
|
set(result_incs -I${arg} ${result_incs})
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${_object_file}
|
|
|
|
COMMAND nasm -o ${_object_file} ${result_incs} ${result_defs} -f bin ${_asm_file}
|
|
|
|
DEPENDS ${_asm_file})
|
|
|
|
set_source_files_properties(${_object_file} PROPERTIES GENERATED TRUE)
|
|
|
|
add_custom_target(${_target_name} ALL DEPENDS ${_object_file})
|
2011-08-08 11:45:34 +00:00
|
|
|
endfunction()
|
2011-06-09 13:56:44 +00:00
|
|
|
|
2011-08-08 11:45:34 +00:00
|
|
|
function(CreateBootSectorTarget2 _target_name _asm_file _binary_file _base_address)
|
2011-06-09 13:56:44 +00:00
|
|
|
set(_object_file ${_binary_file}.o)
|
|
|
|
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${_object_file}
|
|
|
|
COMMAND ${CMAKE_ASM_COMPILER} -x assembler-with-cpp -o ${_object_file} -I${REACTOS_SOURCE_DIR}/include/asm -I${REACTOS_BINARY_DIR}/include/asm -D__ASM__ -c ${_asm_file}
|
|
|
|
DEPENDS ${_asm_file})
|
|
|
|
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${_binary_file}
|
|
|
|
COMMAND native-obj2bin ${_object_file} ${_binary_file} ${_base_address}
|
|
|
|
# COMMAND objcopy --output-target binary --image-base 0x${_base_address} ${_object_file} ${_binary_file}
|
2011-08-05 20:40:40 +00:00
|
|
|
DEPENDS ${_object_file} native-obj2bin)
|
2011-06-09 13:56:44 +00:00
|
|
|
|
|
|
|
set_source_files_properties(${_object_file} ${_binary_file} PROPERTIES GENERATED TRUE)
|
|
|
|
|
|
|
|
add_custom_target(${_target_name} ALL DEPENDS ${_binary_file})
|
|
|
|
|
2011-08-08 11:45:34 +00:00
|
|
|
endfunction()
|
2011-09-04 17:32:30 +00:00
|
|
|
|
|
|
|
function(allow_warnings __module)
|
2011-09-04 21:52:37 +00:00
|
|
|
add_target_compile_flags(${__module} "-Wno-error")
|
2011-09-04 17:32:30 +00:00
|
|
|
endfunction()
|