mirror of
https://github.com/reactos/reactos.git
synced 2025-01-10 16:18:16 +00:00
[CMAKE]
- Move spec2def into comppiler specific files, use spec2pdef tool on MSVC builds - Add a ridiculously complex macro to create the importlibs for MSVC. (It was hard for me to figure this out, so be it for you ;-)) svn path=/branches/cmake-bringup/; revision=49545
This commit is contained in:
parent
f655f86d82
commit
2b5855372c
3 changed files with 141 additions and 100 deletions
|
@ -1,4 +1,4 @@
|
|||
|
||||
|
||||
MACRO(_PCH_GET_COMPILE_FLAGS _target_name _out_compile_flags _header_filename)
|
||||
|
||||
# Add the precompiled header to the build
|
||||
|
@ -41,16 +41,6 @@ MACRO(add_pch _target_name _header_filename _src_list)
|
|||
|
||||
ENDMACRO(add_pch _target_name _header_filename _src_list)
|
||||
|
||||
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)
|
||||
|
||||
if (NOT MSVC)
|
||||
MACRO(CreateBootSectorTarget _target_name _asm_file _object_file)
|
||||
|
||||
|
@ -116,85 +106,85 @@ MACRO(ADD_INTERFACE_DEFINITIONS TARGET)
|
|||
ENDMACRO()
|
||||
|
||||
MACRO(add_minicd_target _targetname _dir) # optional parameter: _nameoncd
|
||||
if("${ARGN}" STREQUAL "")
|
||||
get_target_property(FILENAME ${_targetname} LOCATION)
|
||||
get_filename_component(_nameoncd ${FILENAME} NAME)
|
||||
else()
|
||||
set(_nameoncd ${ARGN})
|
||||
endif()
|
||||
|
||||
if("${ARGN}" STREQUAL "")
|
||||
get_target_property(FILENAME ${_targetname} LOCATION)
|
||||
get_filename_component(_nameoncd ${FILENAME} NAME)
|
||||
else()
|
||||
set(_nameoncd ${ARGN})
|
||||
endif()
|
||||
|
||||
file(APPEND ${REACTOS_BINARY_DIR}/boot/ros_minicd_target.txt "${_targetname}\t${_dir}\t${_nameoncd}\n")
|
||||
ENDMACRO(add_minicd_target)
|
||||
|
||||
MACRO(add_minicd FILENAME _dir _nameoncd)
|
||||
file(APPEND ${REACTOS_BINARY_DIR}/boot/ros_minicd.txt "${FILENAME}\t${_dir}\t${_nameoncd}\n")
|
||||
ENDMACRO(add_minicd)
|
||||
|
||||
macro(set_cpp)
|
||||
include_directories(BEFORE ${REACTOS_SOURCE_DIR}/lib/3rdparty/stlport/stlport)
|
||||
set(IS_CPP 1)
|
||||
endmacro()
|
||||
|
||||
|
||||
macro(set_cpp)
|
||||
include_directories(BEFORE ${REACTOS_SOURCE_DIR}/lib/3rdparty/stlport/stlport)
|
||||
set(IS_CPP 1)
|
||||
endmacro()
|
||||
|
||||
MACRO(add_livecd_target _targetname _dir )# optional parameter : _nameoncd
|
||||
if("${ARGN}" STREQUAL "")
|
||||
if("${ARGN}" STREQUAL "")
|
||||
get_target_property(FILENAME ${_targetname} LOCATION)
|
||||
get_filename_component(_nameoncd ${FILENAME} NAME)
|
||||
else()
|
||||
set(_nameoncd ${ARGN})
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
file(APPEND ${REACTOS_BINARY_DIR}/boot/ros_livecd_target.txt "${_targetname}\t${_dir}\t${_nameoncd}\n")
|
||||
ENDMACRO(add_livecd_target)
|
||||
|
||||
MACRO(add_livecd FILENAME _dir)# optional parameter : _nameoncd
|
||||
if("${ARGN}" STREQUAL "")
|
||||
get_filename_component(_nameoncd ${FILENAME} NAME)
|
||||
else()
|
||||
set(_nameoncd ${ARGN})
|
||||
endif()
|
||||
file(APPEND ${REACTOS_BINARY_DIR}/boot/ros_livecd.txt "${FILENAME}\t${_dir}\t${_nameoncd}\n")
|
||||
ENDMACRO(add_livecd)
|
||||
|
||||
macro(cab_to_dir _dir_num _var_name)
|
||||
# 1 = system32
|
||||
# 2 = system32\drivers
|
||||
# 3 = Fonts
|
||||
# 4 =
|
||||
# 5 = system32\drivers\etc
|
||||
# 6 = inf
|
||||
# 7 = bin
|
||||
# 8 = media
|
||||
if(${_dir_num} STREQUAL "1")
|
||||
set(${_var_name} "reactos/system32")
|
||||
elseif(${_dir_num} STREQUAL "2")
|
||||
set(${_var_name} "reactos/system32/drivers")
|
||||
elseif(${_dir_num} STREQUAL "3")
|
||||
set(${_var_name} "reactos/fonts")
|
||||
elseif(${_dir_num} STREQUAL "4")
|
||||
set(${_var_name} "reactos")
|
||||
elseif(${_dir_num} STREQUAL "5")
|
||||
set(${_var_name} "reactos/system32/drivers/etc")
|
||||
elseif(${_dir_num} STREQUAL "6")
|
||||
set(${_var_name} "reactos/inf")
|
||||
elseif(${_dir_num} STREQUAL "7")
|
||||
set(${_var_name} "reactos/bin")
|
||||
elseif(${_dir_num} STREQUAL "8")
|
||||
set(${_var_name} "reactos/system32/drivers")
|
||||
else()
|
||||
message(FATAL_ERROR "Wrong directory ${_dir_num}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
MACRO(add_cab_target _targetname _num )
|
||||
file(APPEND ${REACTOS_BINARY_DIR}/boot/ros_cab_target.txt "${_targetname}\t${_num}\n")
|
||||
cab_to_dir(${_num} _dir)
|
||||
add_livecd_target(${_targetname} ${_dir})
|
||||
ENDMACRO(add_cab_target)
|
||||
|
||||
MACRO(add_cab FILENAME _num)
|
||||
file(APPEND ${REACTOS_BINARY_DIR}/boot/ros_cab.txt "${FILENAME}\t${_num}\n")
|
||||
cab_to_dir(${_num} _dir)
|
||||
add_livecd(${FILENAME} ${_dir})
|
||||
ENDMACRO(add_livecd_target)
|
||||
|
||||
MACRO(add_livecd FILENAME _dir)# optional parameter : _nameoncd
|
||||
if("${ARGN}" STREQUAL "")
|
||||
get_filename_component(_nameoncd ${FILENAME} NAME)
|
||||
else()
|
||||
set(_nameoncd ${ARGN})
|
||||
endif()
|
||||
file(APPEND ${REACTOS_BINARY_DIR}/boot/ros_livecd.txt "${FILENAME}\t${_dir}\t${_nameoncd}\n")
|
||||
ENDMACRO(add_livecd)
|
||||
|
||||
macro(cab_to_dir _dir_num _var_name)
|
||||
# 1 = system32
|
||||
# 2 = system32\drivers
|
||||
# 3 = Fonts
|
||||
# 4 =
|
||||
# 5 = system32\drivers\etc
|
||||
# 6 = inf
|
||||
# 7 = bin
|
||||
# 8 = media
|
||||
if(${_dir_num} STREQUAL "1")
|
||||
set(${_var_name} "reactos/system32")
|
||||
elseif(${_dir_num} STREQUAL "2")
|
||||
set(${_var_name} "reactos/system32/drivers")
|
||||
elseif(${_dir_num} STREQUAL "3")
|
||||
set(${_var_name} "reactos/fonts")
|
||||
elseif(${_dir_num} STREQUAL "4")
|
||||
set(${_var_name} "reactos")
|
||||
elseif(${_dir_num} STREQUAL "5")
|
||||
set(${_var_name} "reactos/system32/drivers/etc")
|
||||
elseif(${_dir_num} STREQUAL "6")
|
||||
set(${_var_name} "reactos/inf")
|
||||
elseif(${_dir_num} STREQUAL "7")
|
||||
set(${_var_name} "reactos/bin")
|
||||
elseif(${_dir_num} STREQUAL "8")
|
||||
set(${_var_name} "reactos/system32/drivers")
|
||||
else()
|
||||
message(FATAL_ERROR "Wrong directory ${_dir_num}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
MACRO(add_cab_target _targetname _num )
|
||||
file(APPEND ${REACTOS_BINARY_DIR}/boot/ros_cab_target.txt "${_targetname}\t${_num}\n")
|
||||
cab_to_dir(${_num} _dir)
|
||||
add_livecd_target(${_targetname} ${_dir})
|
||||
ENDMACRO(add_cab_target)
|
||||
|
||||
MACRO(add_cab FILENAME _num)
|
||||
file(APPEND ${REACTOS_BINARY_DIR}/boot/ros_cab.txt "${FILENAME}\t${_num}\n")
|
||||
cab_to_dir(${_num} _dir)
|
||||
add_livecd(${FILENAME} ${_dir})
|
||||
ENDMACRO(add_cab)
|
||||
|
||||
macro(custom_incdefs)
|
||||
|
@ -251,8 +241,8 @@ macro (MACRO_IDL_FILES)
|
|||
get_filename_component(FILE ${_in_FILE} NAME_WE)
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${FILE}_s.h ${CMAKE_CURRENT_BINARY_DIR}/${FILE}_s.c
|
||||
COMMAND ${IDL_COMPILER} ${result_incs} ${result_defs} ${IDL_FLAGS} ${IDL_HEADER_ARG} ${CMAKE_CURRENT_BINARY_DIR}/${FILE}_s.h ${IDL_SERVER_ARG} ${CMAKE_CURRENT_BINARY_DIR}/${FILE}_s.c ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}.idl
|
||||
DEPENDS ${_in_file})
|
||||
COMMAND ${IDL_COMPILER} ${result_incs} ${result_defs} ${IDL_FLAGS} ${IDL_HEADER_ARG} ${CMAKE_CURRENT_BINARY_DIR}/${FILE}_s.h ${IDL_SERVER_ARG} ${CMAKE_CURRENT_BINARY_DIR}/${FILE}_s.c ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}.idl
|
||||
DEPENDS ${_in_file})
|
||||
set_source_files_properties(
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${FILE}_s.h ${CMAKE_CURRENT_BINARY_DIR}/${FILE}_s.c
|
||||
PROPERTIES GENERATED TRUE)
|
||||
|
@ -261,8 +251,8 @@ macro (MACRO_IDL_FILES)
|
|||
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${FILE}_c.h ${CMAKE_CURRENT_BINARY_DIR}/${FILE}_c.c
|
||||
COMMAND ${IDL_COMPILER} ${result_incs} ${result_defs} ${IDL_FLAGS} ${IDL_HEADER_ARG} ${CMAKE_CURRENT_BINARY_DIR}/${FILE}_c.h ${IDL_CLIENT_ARG} ${CMAKE_CURRENT_BINARY_DIR}/${FILE}_c.c ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}.idl
|
||||
DEPENDS ${_in_file})
|
||||
COMMAND ${IDL_COMPILER} ${result_incs} ${result_defs} ${IDL_FLAGS} ${IDL_HEADER_ARG} ${CMAKE_CURRENT_BINARY_DIR}/${FILE}_c.h ${IDL_CLIENT_ARG} ${CMAKE_CURRENT_BINARY_DIR}/${FILE}_c.c ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}.idl
|
||||
DEPENDS ${_in_file})
|
||||
set_source_files_properties(
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${FILE}_c.h ${CMAKE_CURRENT_BINARY_DIR}/${FILE}_c.c
|
||||
PROPERTIES GENERATED TRUE)
|
||||
|
@ -271,16 +261,16 @@ macro (MACRO_IDL_FILES)
|
|||
endforeach(_in_FILE ${ARGN})
|
||||
|
||||
endmacro (MACRO_IDL_FILES)
|
||||
|
||||
macro(ADD_TYPELIB TARGET)
|
||||
custom_incdefs()
|
||||
foreach(SOURCE ${ARGN})
|
||||
get_filename_component(FILE ${SOURCE} NAME_WE)
|
||||
set(OBJECT ${CMAKE_CURRENT_BINARY_DIR}/${FILE}.tlb)
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${FILE}.tlb
|
||||
COMMAND ${IDL_COMPILER} ${result_incs} ${IDL_FLAGS} ${IDL_TYPELIB_ARG} ${CMAKE_CURRENT_BINARY_DIR}/${FILE}.tlb ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE}
|
||||
DEPENDS ${SOURCE})
|
||||
list(APPEND OBJECTS ${OBJECT})
|
||||
endforeach()
|
||||
add_custom_target(${TARGET} ALL DEPENDS ${OBJECTS})
|
||||
endmacro()
|
||||
|
||||
macro(ADD_TYPELIB TARGET)
|
||||
custom_incdefs()
|
||||
foreach(SOURCE ${ARGN})
|
||||
get_filename_component(FILE ${SOURCE} NAME_WE)
|
||||
set(OBJECT ${CMAKE_CURRENT_BINARY_DIR}/${FILE}.tlb)
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${FILE}.tlb
|
||||
COMMAND ${IDL_COMPILER} ${result_incs} ${IDL_FLAGS} ${IDL_TYPELIB_ARG} ${CMAKE_CURRENT_BINARY_DIR}/${FILE}.tlb ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE}
|
||||
DEPENDS ${SOURCE})
|
||||
list(APPEND OBJECTS ${OBJECT})
|
||||
endforeach()
|
||||
add_custom_target(${TARGET} ALL DEPENDS ${OBJECTS})
|
||||
endmacro()
|
||||
|
|
10
gcc.cmake
10
gcc.cmake
|
@ -158,6 +158,16 @@ macro(add_importlib_target _def_file)
|
|||
# empty for now, while import libs are shipped
|
||||
endmacro()
|
||||
|
||||
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)
|
||||
|
||||
macro(pdef2def _pdef_file)
|
||||
get_filename_component(_file ${_pdef_file} NAME_WE)
|
||||
add_custom_command(
|
||||
|
|
51
msc.cmake
51
msc.cmake
|
@ -56,6 +56,8 @@ macro(set_module_type MODULE TYPE)
|
|||
endif()
|
||||
if (${TYPE} MATCHES win32gui)
|
||||
set_subsystem(${MODULE} windows)
|
||||
set_entrypoint(${MODULE} WinMainCRTStartup)
|
||||
target_link_libraries(${MODULE} mingw_common mingw_wmain)
|
||||
endif ()
|
||||
if (${TYPE} MATCHES win32cui)
|
||||
set_subsystem(${MODULE} console)
|
||||
|
@ -72,6 +74,7 @@ macro(set_module_type MODULE TYPE)
|
|||
endif()
|
||||
target_link_libraries(${MODULE} mingw_common mingw_dllmain)
|
||||
add_importlibs(${MODULE} msvcrt kernel32)
|
||||
add_linkerflag(${MODULE} "/DLL")
|
||||
endif()
|
||||
|
||||
endmacro()
|
||||
|
@ -89,20 +92,48 @@ endmacro()
|
|||
|
||||
#idl files support
|
||||
set(IDL_COMPILER midl)
|
||||
set(IDL_FLAGS /win32)
|
||||
set(IDL_FLAGS /win32 /Dstrict_context_handle=)
|
||||
set(IDL_HEADER_ARG /h) #.h
|
||||
set(IDL_TYPELIB_ARG /tlb) #.tlb
|
||||
set(IDL_SERVER_ARG /sstub) #.c for stub server library
|
||||
set(IDL_CLIENT_ARG /cstub) #.c for stub client library
|
||||
|
||||
# Thanks MS for creating a stupid linker
|
||||
macro(add_importlib_target _spec_file)
|
||||
get_filename_component(_name ${_spec_file} NAME_WE)
|
||||
|
||||
macro(add_importlib_target _def_file)
|
||||
get_filename_component(_name ${_def_file} NAME_WE)
|
||||
# Generate the asm stub file
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_BINARY_DIR}/importlibs/lib${_name}_stubs.asm
|
||||
COMMAND native-spec2pdef -s ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file} ${CMAKE_BINARY_DIR}/importlibs/lib${_name}_stubs.asm
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file})
|
||||
|
||||
# Generate a the export def file
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_BINARY_DIR}/importlibs/lib${_name}_exp.def
|
||||
COMMAND native-spec2pdef -n -r ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file} ${CMAKE_BINARY_DIR}/importlibs/lib${_name}_exp.def
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file})
|
||||
|
||||
# Assemble the file
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_BINARY_DIR}/importlibs/lib${_name}_stubs.obj
|
||||
COMMAND ${CMAKE_ASM_COMPILER} /Fo${CMAKE_BINARY_DIR}/importlibs/lib${_name}_stubs.obj /c /Ta ${CMAKE_BINARY_DIR}/importlibs/lib${_name}_stubs.asm
|
||||
DEPENDS "${CMAKE_BINARY_DIR}/importlibs/lib${_name}_stubs.asm"
|
||||
)
|
||||
|
||||
# Add neccessary importlibs for redirections
|
||||
foreach(_lib ${ARGN})
|
||||
list(APPEND _libraries "${CMAKE_BINARY_DIR}/importlibs/${_lib}.lib")
|
||||
endforeach()
|
||||
|
||||
# Build the importlib
|
||||
add_custom_command(
|
||||
OUTPUT {CMAKE_BINARY_DIR}/importlibs/lib${_name}.lib
|
||||
COMMAND LINK /LIB /MACHINE:X86 /DEF:${_def_file} /OUT:${CMAKE_BINARY_DIR}/importlibs/lib${_name}.lib
|
||||
DEPENDS ${_def_file}
|
||||
COMMAND LINK /LIB /MACHINE:X86 /DEF:${CMAKE_BINARY_DIR}/importlibs/lib${_name}_exp.def /OUT:${CMAKE_BINARY_DIR}/importlibs/lib${_name}.lib ${CMAKE_BINARY_DIR}/importlibs/lib${_name}_stubs.obj ${_libraries}
|
||||
DEPENDS "${CMAKE_BINARY_DIR}/importlibs/lib${_name}_stubs.obj" "${CMAKE_BINARY_DIR}/importlibs/lib${_name}_exp.def" ${_libraries}
|
||||
)
|
||||
|
||||
# Add the importlib target
|
||||
add_custom_target(
|
||||
lib${_name}
|
||||
DEPENDS {CMAKE_BINARY_DIR}/importlibs/lib${_name}.lib
|
||||
|
@ -116,6 +147,16 @@ macro(add_importlibs MODULE)
|
|||
endforeach()
|
||||
endmacro()
|
||||
|
||||
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-spec2pdef -n --dll ${_dllname} ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file} ${CMAKE_CURRENT_BINARY_DIR}/${_file}.def
|
||||
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)
|
||||
|
||||
macro(pdef2def _pdef_file)
|
||||
get_filename_component(_file ${_pdef_file} NAME_WE)
|
||||
add_custom_command(
|
||||
|
|
Loading…
Reference in a new issue