mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 22:32:58 +00:00
[CMAKE]
- Improve amd64 toolchain support. svn path=/branches/cmake-bringup/; revision=50171
This commit is contained in:
parent
c44d0d4055
commit
0e74512f1e
5 changed files with 253 additions and 167 deletions
|
@ -3,14 +3,22 @@ cmake_minimum_required(VERSION 2.8)
|
||||||
project(REACTOS)
|
project(REACTOS)
|
||||||
|
|
||||||
# Compile options
|
# Compile options
|
||||||
|
if(ARCH MATCHES i386)
|
||||||
include(config.cmake)
|
include(config.cmake)
|
||||||
|
elseif(ARCH MATCHES amd64)
|
||||||
|
include(config-amd64.cmake)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(NOT CMAKE_CROSSCOMPILING)
|
if(NOT CMAKE_CROSSCOMPILING)
|
||||||
|
|
||||||
|
if(ARCH MATCHES i386)
|
||||||
add_definitions(-DTARGET_i386)
|
add_definitions(-DTARGET_i386)
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
add_definitions(-Dinline=__inline)
|
add_definitions(-Dinline=__inline)
|
||||||
endif()
|
endif()
|
||||||
|
elseif(ARCH MATCHES amd64)
|
||||||
|
add_definitions(-DTARGET_amd64)
|
||||||
|
endif()
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
${REACTOS_SOURCE_DIR}/tools/unicode
|
${REACTOS_SOURCE_DIR}/tools/unicode
|
||||||
|
@ -84,27 +92,34 @@ enable_language(ASM)
|
||||||
# Activate language support for resource files
|
# Activate language support for resource files
|
||||||
enable_language(RC)
|
enable_language(RC)
|
||||||
|
|
||||||
|
|
||||||
if(DBG)
|
if(DBG)
|
||||||
add_definitions(-DDBG=1 -D_SEH_ENABLE_TRACE)
|
add_definitions(-DDBG=1 -D_SEH_ENABLE_TRACE)
|
||||||
else()
|
else()
|
||||||
add_definitions(-DDBG=0)
|
add_definitions(-DDBG=0)
|
||||||
endif(DBG)
|
endif()
|
||||||
|
|
||||||
if(KDBG)
|
if(KDBG)
|
||||||
add_definitions(-DKDBG=1)
|
add_definitions(-DKDBG=1)
|
||||||
else()
|
else()
|
||||||
add_definitions(-DKDBG=0)
|
add_definitions(-DKDBG=0)
|
||||||
endif(KDBG)
|
endif()
|
||||||
|
|
||||||
# Version Options
|
# Version Options
|
||||||
add_definitions(-DWINVER=0x502 -D_WIN32_IE=0x600 -D_WIN32_WINNT=0x502 -D_WIN32_WINDOWS=0x502 -D_SETUPAPI_VER=0x502)
|
add_definitions(-DWINVER=0x502 -D_WIN32_IE=0x600 -D_WIN32_WINNT=0x502 -D_WIN32_WINDOWS=0x502 -D_SETUPAPI_VER=0x502)
|
||||||
|
|
||||||
# Arch Options
|
# Arch Options
|
||||||
|
if(ARCH MATCHES i386)
|
||||||
add_definitions(-D_M_IX86 -D_X86_ -D__i386__)
|
add_definitions(-D_M_IX86 -D_X86_ -D__i386__)
|
||||||
|
elseif(ARCH MATCHES amd64)
|
||||||
|
add_definitions(-D_M_AMD64 -D_AMD64_ -D_M_AXP64 -D__x86_64__ -D_WIN64)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Other
|
# Other
|
||||||
|
if(ARCH MATCHES i386)
|
||||||
add_definitions(-DUSE_COMPILER_EXCEPTIONS -D_USE_32BIT_TIME_T)
|
add_definitions(-DUSE_COMPILER_EXCEPTIONS -D_USE_32BIT_TIME_T)
|
||||||
|
elseif(ARCH MATCHES amd64)
|
||||||
|
add_definitions(-DUSE_COMPILER_EXCEPTIONS -DNO_UNDERSCORE_PREFIX)
|
||||||
|
endif()
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
include
|
include
|
||||||
|
@ -124,7 +139,7 @@ if(MSVC)
|
||||||
include_directories(include/crt/msc)
|
include_directories(include/crt/msc)
|
||||||
else()
|
else()
|
||||||
include_directories(include/crt/mingw32)
|
include_directories(include/crt/mingw32)
|
||||||
endif(MSVC)
|
endif()
|
||||||
|
|
||||||
add_subdirectory(include/psdk)
|
add_subdirectory(include/psdk)
|
||||||
add_subdirectory(include/dxsdk)
|
add_subdirectory(include/dxsdk)
|
||||||
|
|
|
@ -241,10 +241,15 @@ endmacro()
|
||||||
|
|
||||||
macro(add_idl_interface IDL_FILE)
|
macro(add_idl_interface IDL_FILE)
|
||||||
custom_incdefs()
|
custom_incdefs()
|
||||||
|
if(ARCH MATCHES i386)
|
||||||
|
set(platform_flags "-m32 --win32")
|
||||||
|
elseif(ARCH MATCHES amd64)
|
||||||
|
set(platform_flags "-m64 --win64")
|
||||||
|
endif()
|
||||||
get_filename_component(FILE ${IDL_FILE} NAME_WE)
|
get_filename_component(FILE ${IDL_FILE} NAME_WE)
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${FILE}_i.c
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${FILE}_i.c
|
||||||
COMMAND ${IDL_COMPILER} ${result_incs} ${result_defs} -m32 --win32 -u -U ${CMAKE_CURRENT_BINARY_DIR}/${FILE}_i.c ${CMAKE_CURRENT_SOURCE_DIR}/${IDL_FILE}
|
COMMAND ${IDL_COMPILER} ${result_incs} ${result_defs} ${platform_flags} -u -U ${CMAKE_CURRENT_BINARY_DIR}/${FILE}_i.c ${CMAKE_CURRENT_SOURCE_DIR}/${IDL_FILE}
|
||||||
DEPENDS ${IDL_FILE})
|
DEPENDS ${IDL_FILE})
|
||||||
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${FILE}_i.c PROPERTIES GENERATED TRUE)
|
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${FILE}_i.c PROPERTIES GENERATED TRUE)
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
43
config-amd64.cmake
Normal file
43
config-amd64.cmake
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
|
||||||
|
set(SARCH "" CACHE STRING
|
||||||
|
"Sub-architecture to build for.")
|
||||||
|
|
||||||
|
set(OARCH "athlon64" CACHE STRING
|
||||||
|
"Generate instructions for this CPU type. Specify one of:
|
||||||
|
k8 opteron athlon64 athlon-fx")
|
||||||
|
|
||||||
|
set (OPTIMIZE "1" CACHE STRING
|
||||||
|
"What level of optimisation to use.
|
||||||
|
0 = off
|
||||||
|
1 = Default option, optimize for size (-Os) with some additional options
|
||||||
|
2 = -Os
|
||||||
|
3 = -O1
|
||||||
|
4 = -O2
|
||||||
|
5 = -O3")
|
||||||
|
|
||||||
|
set(DBG TRUE CACHE BOOL
|
||||||
|
"Whether to compile for debugging.")
|
||||||
|
|
||||||
|
set(KDBG FALSE CACHE BOOL
|
||||||
|
"Whether to compile in the integrated kernel debugger.")
|
||||||
|
|
||||||
|
set(GDB FALSE CACHE BOOL
|
||||||
|
"Whether to compile for debugging with GDB.
|
||||||
|
If you don't use GDB, don't enable this.")
|
||||||
|
|
||||||
|
set(_WINKD_ TRUE CACHE BOOL
|
||||||
|
"Whether to compile with the KD protocol.")
|
||||||
|
|
||||||
|
set(_ELF_ FALSE CACHE BOOL
|
||||||
|
"Whether to compile support for ELF files.
|
||||||
|
Do not enable unless you know what you're doing.")
|
||||||
|
|
||||||
|
set(NSWPAT FALSE CACHE BOOL
|
||||||
|
"Whether to compile apps/libs with features covered software patents or not.
|
||||||
|
If you live in a country where software patents are valid/apply, don't
|
||||||
|
enable this (except they/you purchased a license from the patent owner).
|
||||||
|
This settings is disabled (0) by default.")
|
||||||
|
|
||||||
|
set(USERMODE TRUE CACHE BOOL
|
||||||
|
"Whether to compile any usermode parts. This is while kernel mode is under
|
||||||
|
heavy development and usermode part not relevant for bootcd.")
|
38
gcc.cmake
38
gcc.cmake
|
@ -24,16 +24,29 @@ set(CMAKE_RC_CREATE_SHARED_LIBRARY "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_C_F
|
||||||
add_definitions(-gdwarf-2 -g2 -femit-struct-debug-detailed=none -feliminate-unused-debug-types)
|
add_definitions(-gdwarf-2 -g2 -femit-struct-debug-detailed=none -feliminate-unused-debug-types)
|
||||||
|
|
||||||
# Tuning
|
# Tuning
|
||||||
add_definitions(-march=pentium -mtune=i686)
|
if(ARCH MATCHES i386)
|
||||||
|
add_definitions(-march=${OARCH} -mtune=${TUNE})
|
||||||
|
elseif(ARCH MATCHES amd64)
|
||||||
|
add_definitions(-march=${OARCH})
|
||||||
|
endif()
|
||||||
|
|
||||||
# Warnings
|
# Warnings
|
||||||
add_definitions(-Wall -Wno-char-subscripts -Wpointer-arith -Wno-multichar -Wno-error=uninitialized -Wno-unused-value -Winvalid-pch)
|
add_definitions(-Wall -Wno-char-subscripts -Wpointer-arith -Wno-multichar -Wno-error=uninitialized -Wno-unused-value -Winvalid-pch)
|
||||||
|
|
||||||
# Optimizations
|
# Optimizations
|
||||||
|
if(ARCH MATCHES i386)
|
||||||
add_definitions(-Os -fno-strict-aliasing -ftracer -momit-leaf-frame-pointer -mpreferred-stack-boundary=2 -fno-set-stack-executable -fno-optimize-sibling-calls)
|
add_definitions(-Os -fno-strict-aliasing -ftracer -momit-leaf-frame-pointer -mpreferred-stack-boundary=2 -fno-set-stack-executable -fno-optimize-sibling-calls)
|
||||||
|
elseif(ARCH MATCHES amd64)
|
||||||
|
add_definitions(-Os -fno-strict-aliasing -ftracer -momit-leaf-frame-pointer -mpreferred-stack-boundary=4)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Other
|
||||||
|
if(ARCH MATCHES amd64)
|
||||||
|
add_definitions(-U_X86_ -UWIN32)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Macros
|
# Macros
|
||||||
MACRO(_PCH_GET_COMPILE_FLAGS _target_name _out_compile_flags _header_filename)
|
macro(_PCH_GET_COMPILE_FLAGS _target_name _out_compile_flags _header_filename)
|
||||||
# Add the precompiled header to the build
|
# Add the precompiled header to the build
|
||||||
get_filename_component(FILE ${_header_filename} NAME)
|
get_filename_component(FILE ${_header_filename} NAME)
|
||||||
set(_gch_filename "${_target_name}_${FILE}.gch")
|
set(_gch_filename "${_target_name}_${FILE}.gch")
|
||||||
|
@ -43,7 +56,7 @@ MACRO(_PCH_GET_COMPILE_FLAGS _target_name _out_compile_flags _header_filename)
|
||||||
get_directory_property(DIRINC INCLUDE_DIRECTORIES)
|
get_directory_property(DIRINC INCLUDE_DIRECTORIES)
|
||||||
foreach(item ${DIRINC})
|
foreach(item ${DIRINC})
|
||||||
list(APPEND ${_out_compile_flags} -I${item})
|
list(APPEND ${_out_compile_flags} -I${item})
|
||||||
endforeach(item)
|
endforeach()
|
||||||
|
|
||||||
# This is a particular bit of undocumented/hacky magic I'm quite proud of
|
# This is a particular bit of undocumented/hacky magic I'm quite proud of
|
||||||
get_directory_property(_compiler_flags DEFINITIONS)
|
get_directory_property(_compiler_flags DEFINITIONS)
|
||||||
|
@ -55,11 +68,11 @@ MACRO(_PCH_GET_COMPILE_FLAGS _target_name _out_compile_flags _header_filename)
|
||||||
if (_target_defs)
|
if (_target_defs)
|
||||||
foreach(item ${_target_defs})
|
foreach(item ${_target_defs})
|
||||||
list(APPEND ${_out_compile_flags} -D${item})
|
list(APPEND ${_out_compile_flags} -D${item})
|
||||||
endforeach(item)
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
ENDMACRO(_PCH_GET_COMPILE_FLAGS)
|
endmacro()
|
||||||
|
|
||||||
MACRO(add_pch _target_name _header_filename _src_list)
|
macro(add_pch _target_name _header_filename _src_list)
|
||||||
get_filename_component(FILE ${_header_filename} NAME)
|
get_filename_component(FILE ${_header_filename} NAME)
|
||||||
set(_gch_filename "${_target_name}_${FILE}.gch")
|
set(_gch_filename "${_target_name}_${FILE}.gch")
|
||||||
list(APPEND ${_src_list} ${_gch_filename})
|
list(APPEND ${_src_list} ${_gch_filename})
|
||||||
|
@ -69,7 +82,7 @@ MACRO(add_pch _target_name _header_filename _src_list)
|
||||||
OUTPUT ${_gch_filename}
|
OUTPUT ${_gch_filename}
|
||||||
COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1} ${_args}
|
COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1} ${_args}
|
||||||
DEPENDS ${_header_filename})
|
DEPENDS ${_header_filename})
|
||||||
ENDMACRO(add_pch _target_name _header_filename _src_list)
|
endmacro()
|
||||||
|
|
||||||
macro(add_linkerflag MODULE _flag)
|
macro(add_linkerflag MODULE _flag)
|
||||||
set(NEW_LINKER_FLAGS ${_flag})
|
set(NEW_LINKER_FLAGS ${_flag})
|
||||||
|
@ -99,7 +112,6 @@ endmacro()
|
||||||
macro(set_module_type MODULE TYPE)
|
macro(set_module_type MODULE TYPE)
|
||||||
|
|
||||||
add_dependencies(${MODULE} psdk buildno_header)
|
add_dependencies(${MODULE} psdk buildno_header)
|
||||||
|
|
||||||
if(${IS_CPP})
|
if(${IS_CPP})
|
||||||
target_link_libraries(${MODULE} stlport -lsupc++ -lgcc)
|
target_link_libraries(${MODULE} stlport -lsupc++ -lgcc)
|
||||||
endif()
|
endif()
|
||||||
|
@ -166,18 +178,24 @@ macro(set_rc_compiler)
|
||||||
|
|
||||||
foreach(arg ${defines})
|
foreach(arg ${defines})
|
||||||
set(rc_result_defs "${rc_result_defs} -D${arg}")
|
set(rc_result_defs "${rc_result_defs} -D${arg}")
|
||||||
endforeach(arg ${defines})
|
endforeach()
|
||||||
|
|
||||||
foreach(arg ${includes})
|
foreach(arg ${includes})
|
||||||
set(rc_result_incs "-I${arg} ${rc_result_incs}")
|
set(rc_result_incs "-I${arg} ${rc_result_incs}")
|
||||||
endforeach(arg ${includes})
|
endforeach()
|
||||||
|
|
||||||
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> ${rc_result_defs} ${rc_result_incs} -i <SOURCE> -O coff -o <OBJECT>")
|
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> ${rc_result_defs} ${rc_result_incs} -i <SOURCE> -O coff -o <OBJECT>")
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
#idl files support
|
#idl files support
|
||||||
set(IDL_COMPILER native-widl)
|
set(IDL_COMPILER native-widl)
|
||||||
|
|
||||||
|
if(ARCH MATCHES i386)
|
||||||
set(IDL_FLAGS -m32 --win32)
|
set(IDL_FLAGS -m32 --win32)
|
||||||
|
elseif(ARCH MATCHES amd64)
|
||||||
|
set(IDL_FLAGS -m64 --win64)
|
||||||
|
endif()
|
||||||
|
|
||||||
set(IDL_HEADER_ARG -h -H) #.h
|
set(IDL_HEADER_ARG -h -H) #.h
|
||||||
set(IDL_TYPELIB_ARG -t -T) #.tlb
|
set(IDL_TYPELIB_ARG -t -T) #.tlb
|
||||||
set(IDL_SERVER_ARG -s -S) #.c for server library
|
set(IDL_SERVER_ARG -s -S) #.c for server library
|
||||||
|
|
|
@ -34,7 +34,12 @@ set(CMAKE_ASM_COMPILER ${MINGW_PREFIX}gcc)
|
||||||
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>")
|
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>")
|
||||||
set(CMAKE_IDL_COMPILER native-widl)
|
set(CMAKE_IDL_COMPILER native-widl)
|
||||||
|
|
||||||
|
if(ARCH MATCHES i386)
|
||||||
set(CMAKE_IDL_COMPILE_OBJECT "<CMAKE_IDL_COMPILER> <FLAGS> <DEFINES> -m32 --win32 -h -H <OBJECT> <SOURCE>")
|
set(CMAKE_IDL_COMPILE_OBJECT "<CMAKE_IDL_COMPILER> <FLAGS> <DEFINES> -m32 --win32 -h -H <OBJECT> <SOURCE>")
|
||||||
|
elseif(ARCH MATCHES amd64)
|
||||||
|
set(CMAKE_IDL_COMPILE_OBJECT "<CMAKE_IDL_COMPILER> <FLAGS> <DEFINES> -m64 --win64 -h -H <OBJECT> <SOURCE>")
|
||||||
|
endif()
|
||||||
|
|
||||||
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> ")
|
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> ")
|
||||||
|
|
||||||
set(CMAKE_C_CREATE_STATIC_LIBRARY "${MINGW_PREFIX}ar crs <TARGET> <LINK_FLAGS> <OBJECTS>")
|
set(CMAKE_C_CREATE_STATIC_LIBRARY "${MINGW_PREFIX}ar crs <TARGET> <LINK_FLAGS> <OBJECTS>")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue