Allow to specify prefix/suffix for GCC and Binutils.

svn path=/trunk/; revision=53730
This commit is contained in:
Dmitry Gorbachev 2011-09-18 00:57:17 +00:00
parent 1a7296bb39
commit fef1e2d451
4 changed files with 34 additions and 28 deletions

View file

@ -86,7 +86,7 @@ set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS
set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
set(CMAKE_EXE_LINKER_FLAGS "-nodefaultlibs -nostdlib -Wl,--enable-auto-image-base -Wl,--disable-auto-import -Wl,--disable-stdcall-fixup")
set(CMAKE_EXE_LINKER_FLAGS "-nostdlib -Wl,--enable-auto-image-base,--disable-auto-import,--disable-stdcall-fixup")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS_INIT} -Wl,--disable-stdcall-fixup")
@ -134,7 +134,7 @@ function(set_module_type_toolchain MODULE TYPE)
endif()
if(${TYPE} STREQUAL kernelmodedriver)
add_target_link_flags(${MODULE} "-Wl,--exclude-all-symbols -Wl,-file-alignment=0x1000 -Wl,-section-alignment=0x1000")
add_target_link_flags(${MODULE} "-Wl,--exclude-all-symbols,-file-alignment=0x1000,-section-alignment=0x1000")
endif()
endfunction()
@ -190,25 +190,25 @@ function(add_importlib_target _exports_file)
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}
COMMAND ${MINGW_PREFIX}dlltool --def ${CMAKE_CURRENT_BINARY_DIR}/${_name}_implib.def --kill-at --output-lib=${CMAKE_BINARY_DIR}/importlibs/lib${_name}.a
COMMAND ${CMAKE_DLLTOOL} --def ${CMAKE_CURRENT_BINARY_DIR}/${_name}_implib.def --kill-at --output-lib=${CMAKE_BINARY_DIR}/importlibs/lib${_name}.a
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file} native-spec2def)
# 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}
COMMAND ${MINGW_PREFIX}dlltool --def ${CMAKE_CURRENT_BINARY_DIR}/${_name}_delayed_implib.def --kill-at --output-delaylib ${CMAKE_BINARY_DIR}/importlibs/lib${_name}_delayed.a
COMMAND ${CMAKE_DLLTOOL} --def ${CMAKE_CURRENT_BINARY_DIR}/${_name}_delayed_implib.def --kill-at --output-delaylib ${CMAKE_BINARY_DIR}/importlibs/lib${_name}_delayed.a
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file} native-spec2def)
elseif(${_extension} STREQUAL ".def")
message("Use of def files for import libs is deprecated: ${_exports_file}")
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/importlibs/lib${_name}.a
COMMAND ${MINGW_PREFIX}dlltool --def ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file} --kill-at --output-lib=${CMAKE_BINARY_DIR}/importlibs/lib${_name}.a
COMMAND ${CMAKE_DLLTOOL} --def ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file} --kill-at --output-lib=${CMAKE_BINARY_DIR}/importlibs/lib${_name}.a
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file})
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/importlibs/lib${_name}_delayed.a
COMMAND ${MINGW_PREFIX}dlltool --def ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file} --kill-at --output-delaylib ${CMAKE_BINARY_DIR}/importlibs/lib${_name}_delayed.a
COMMAND ${CMAKE_DLLTOOL} --def ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file} --kill-at --output-delaylib ${CMAKE_BINARY_DIR}/importlibs/lib${_name}_delayed.a
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file})
else()
message(FATAL_ERROR "Unsupported exports file extension: ${_extension}")
@ -243,7 +243,7 @@ function(spec2def _dllname _spec_file)
endfunction()
macro(macro_mc FILE)
set(COMMAND_MC ${MINGW_PREFIX}windmc -A -b ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}.mc -r ${REACTOS_BINARY_DIR}/include/reactos -h ${REACTOS_BINARY_DIR}/include/reactos)
set(COMMAND_MC ${CMAKE_MC_COMPILER} -A -b ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}.mc -r ${REACTOS_BINARY_DIR}/include/reactos -h ${REACTOS_BINARY_DIR}/include/reactos)
endmacro()
#pseh lib, needed with mingw

View file

@ -65,8 +65,7 @@ add_dependencies(mingw_dllmain psdk)
if(NOT MSVC)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/liboldnames.a
COMMAND ${MINGW_PREFIX}dlltool --def ${CMAKE_CURRENT_SOURCE_DIR}/moldname-msvcrt.def --kill-at --output-lib ${CMAKE_CURRENT_BINARY_DIR}/liboldnames.a
COMMAND ${MINGW_PREFIX}ar -rc ${CMAKE_CURRENT_BINARY_DIR}/liboldnames.a)
COMMAND ${CMAKE_DLLTOOL} --def ${CMAKE_CURRENT_SOURCE_DIR}/moldname-msvcrt.def --kill-at --output-lib ${CMAKE_CURRENT_BINARY_DIR}/liboldnames.a)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/liboldnames.a PROPERTIES GENERATED TRUE)

View file

@ -1,8 +1,7 @@
if(NOT MSVC)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/liboldnames.a
COMMAND ${MINGW_PREFIX}dlltool --def ${CMAKE_CURRENT_SOURCE_DIR}/moldname-msvcrt.def --kill-at --output-lib ${CMAKE_CURRENT_BINARY_DIR}/liboldnames.a
COMMAND ${MINGW_PREFIX}ar -rc ${CMAKE_CURRENT_BINARY_DIR}/liboldnames.a)
COMMAND ${CMAKE_DLLTOOL} --def ${CMAKE_CURRENT_SOURCE_DIR}/moldname-msvcrt.def --kill-at --output-lib ${CMAKE_CURRENT_BINARY_DIR}/liboldnames.a)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/liboldnames.a PROPERTIES GENERATED TRUE)

View file

@ -3,19 +3,25 @@ if(NOT ARCH)
set(ARCH i386)
endif()
# Choose the right MinGW prefix
if(ARCH MATCHES i386)
# Choose the right MinGW toolchain prefix
if (NOT DEFINED MINGW_TOOLCHAIN_PREFIX)
if(ARCH MATCHES i386)
if(CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
set(MINGW_PREFIX "" CACHE STRING "MinGW Prefix")
else()
set(MINGW_PREFIX "mingw32-" CACHE STRING "MinGW Prefix")
endif(CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
if(CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
set(MINGW_TOOLCHAIN_PREFIX "" CACHE STRING "MinGW Toolchain Prefix")
else()
set(MINGW_TOOLCHAIN_PREFIX "mingw32-" CACHE STRING "MinGW Toolchain Prefix")
endif(CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
elseif(ARCH MATCHES amd64)
set(MINGW_PREFIX "x86_64-w64-mingw32-" CACHE STRING "MinGW Prefix")
elseif(ARCH MATCHES arm)
set(MINGW_PREFIX "arm-mingw32ce-" CACHE STRING "MinGW Prefix")
elseif(ARCH MATCHES amd64)
set(MINGW_TOOLCHAIN_PREFIX "x86_64-w64-mingw32-" CACHE STRING "MinGW Toolchain Prefix")
elseif(ARCH MATCHES arm)
set(MINGW_TOOLCHAIN_PREFIX "arm-mingw32ce-" CACHE STRING "MinGW Toolchain Prefix")
endif()
endif()
if (NOT DEFINED MINGW_TOOLCHAIN_SUFFIX)
set(MINGW_TOOLCHAIN_SUFFIX "" CACHE STRING "MinGW Toolchain Suffix")
endif()
if(ENABLE_CCACHE)
@ -28,11 +34,13 @@ endif()
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR i686)
# Which compilers to use for C and C++
set(CMAKE_C_COMPILER ${CCACHE} ${MINGW_PREFIX}gcc)
set(CMAKE_CXX_COMPILER ${CCACHE} ${MINGW_PREFIX}g++)
set(CMAKE_RC_COMPILER ${MINGW_PREFIX}windres)
set(CMAKE_ASM_COMPILER ${MINGW_PREFIX}gcc)
# Which tools to use
set(CMAKE_C_COMPILER ${CCACHE} ${MINGW_TOOLCHAIN_PREFIX}gcc${MINGW_TOOLCHAIN_SUFFIX})
set(CMAKE_CXX_COMPILER ${CCACHE} ${MINGW_TOOLCHAIN_PREFIX}g++${MINGW_TOOLCHAIN_SUFFIX})
set(CMAKE_ASM_COMPILER ${MINGW_TOOLCHAIN_PREFIX}gcc${MINGW_TOOLCHAIN_SUFFIX})
set(CMAKE_MC_COMPILER ${MINGW_TOOLCHAIN_PREFIX}windmc)
set(CMAKE_RC_COMPILER ${MINGW_TOOLCHAIN_PREFIX}windres)
set(CMAKE_DLLTOOL ${MINGW_TOOLCHAIN_PREFIX}dlltool)
if(NOT CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
set(CMAKE_C_CREATE_STATIC_LIBRARY "<CMAKE_AR> crs <TARGET> <LINK_FLAGS> <OBJECTS>")
@ -46,4 +54,4 @@ set(CMAKE_C_STANDARD_LIBRARIES "-lgcc" CACHE STRING "Standard C Libraries")
#MARK_AS_ADVANCED(CLEAR CMAKE_CXX_STANDARD_LIBRARIES)
set(CMAKE_CXX_STANDARD_LIBRARIES "" CACHE STRING "Standard C++ Libraries")
set(CMAKE_SHARED_LINKER_FLAGS_INIT "-nodefaultlibs -nostdlib -Wl,--enable-auto-image-base -Wl,--disable-auto-import")
set(CMAKE_SHARED_LINKER_FLAGS_INIT "-nostdlib -Wl,--enable-auto-image-base,--disable-auto-import")