2011-05-16 13:12:07 +00:00
|
|
|
|
2012-08-27 18:58:27 +00:00
|
|
|
#if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
|
|
|
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
2011-10-04 14:20:25 +00:00
|
|
|
# no optimization
|
2011-05-16 13:12:07 +00:00
|
|
|
elseif(OPTIMIZE STREQUAL "1")
|
|
|
|
add_definitions(/O1)
|
|
|
|
elseif(OPTIMIZE STREQUAL "2")
|
|
|
|
add_definitions(/O2)
|
|
|
|
elseif(OPTIMIZE STREQUAL "3")
|
|
|
|
add_definitions(/Ot /Ox /GS-)
|
|
|
|
elseif(OPTIMIZE STREQUAL "4")
|
|
|
|
add_definitions(/Os /Ox /GS-)
|
|
|
|
elseif(OPTIMIZE STREQUAL "5")
|
|
|
|
add_definitions(/GF /Gy /Ob2 /Os /Ox /GS-)
|
|
|
|
endif()
|
|
|
|
|
2012-08-27 18:58:27 +00:00
|
|
|
if(ARCH STREQUAL "i386")
|
2011-06-22 11:31:01 +00:00
|
|
|
add_definitions(/DWIN32 /D_WINDOWS)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_definitions(/Dinline=__inline /D__STDC__=1)
|
2011-05-16 13:12:07 +00:00
|
|
|
|
2013-11-15 12:13:25 +00:00
|
|
|
add_compile_flags("/X /GR- /EHs-c- /GS- /Zl /W3")
|
2011-06-22 13:17:37 +00:00
|
|
|
|
2012-07-08 19:59:33 +00:00
|
|
|
# HACK: for VS 11+ we need to explicitly disable SSE, which is off by
|
2013-09-11 19:25:48 +00:00
|
|
|
# default for older compilers. See CORE-6507
|
2013-10-31 09:59:55 +00:00
|
|
|
if(MSVC_VERSION GREATER 1699 AND ARCH STREQUAL "i386")
|
2012-07-08 19:59:33 +00:00
|
|
|
add_compile_flags("/arch:IA32")
|
|
|
|
endif ()
|
|
|
|
|
2013-10-31 09:59:55 +00:00
|
|
|
# VS 12+ requires /FS when used in parallel compilations
|
|
|
|
if(MSVC_VERSION GREATER 1799 AND NOT MSVC_IDE)
|
|
|
|
add_compile_flags("/FS")
|
|
|
|
endif ()
|
|
|
|
|
2014-01-14 21:04:39 +00:00
|
|
|
# Disable overly sensitive warnings as well as those that generally aren't
|
|
|
|
# useful to us.
|
|
|
|
# - TODO: C4018: signed/unsigned mismatch
|
2014-08-31 10:55:32 +00:00
|
|
|
# - C4244: implicit integer truncation
|
2014-01-14 21:04:39 +00:00
|
|
|
# - C4290: C++ exception specification ignored
|
|
|
|
#add_compile_flags("/wd4018 /wd4244 /wd4290")
|
2014-08-31 10:55:32 +00:00
|
|
|
add_compile_flags("/wd4290 /wd4244")
|
2013-09-11 19:25:48 +00:00
|
|
|
|
2013-09-14 13:18:51 +00:00
|
|
|
# The following warnings are treated as errors:
|
2014-01-14 21:04:39 +00:00
|
|
|
# - C4013: implicit function declaration
|
2014-02-28 23:34:32 +00:00
|
|
|
# - C4020: too many actual parameters
|
2013-11-05 20:52:36 +00:00
|
|
|
# - C4022: pointer type mismatch for parameter
|
|
|
|
# - TODO: C4028: formal parameter different from declaration
|
2013-09-14 13:18:51 +00:00
|
|
|
# - C4047: different level of indirection
|
2013-11-05 20:52:36 +00:00
|
|
|
# - TODO: C4090: different 'modifier' qualifiers (for C programs only;
|
2013-09-14 13:18:51 +00:00
|
|
|
# for C++ programs, the compiler error C2440 is issued)
|
|
|
|
# - C4098: void function returning a value
|
2013-11-17 23:38:31 +00:00
|
|
|
# - C4113: parameter lists differ
|
2013-11-05 20:52:36 +00:00
|
|
|
# - C4129: unrecognized escape sequence
|
|
|
|
# - TODO: C4133: incompatible types
|
2014-03-28 01:35:32 +00:00
|
|
|
# - C4163: 'identifier': not available as an intrinsic function
|
2013-11-17 19:45:32 +00:00
|
|
|
# - C4229: modifiers on data are ignored
|
2013-09-14 13:18:51 +00:00
|
|
|
# - C4700: uninitialized variable usage
|
2014-02-12 19:55:12 +00:00
|
|
|
# - C4603: macro is not defined or definition is different after precompiled header use
|
2014-03-28 01:35:32 +00:00
|
|
|
add_compile_flags("/we4013 /we4020 /we4022 /we4047 /we4098 /we4113 /we4129 /we4163 /we4229 /we4700 /we4603")
|
2012-02-23 13:06:11 +00:00
|
|
|
|
2013-11-18 00:04:15 +00:00
|
|
|
# Enable warnings above the default level, but don't treat them as errors:
|
|
|
|
# - C4115: named type definition in parentheses
|
|
|
|
add_compile_flags("/w14115")
|
|
|
|
|
2012-01-14 17:27:17 +00:00
|
|
|
# Debugging
|
2012-08-27 18:58:27 +00:00
|
|
|
#if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
|
|
|
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
2012-05-10 10:39:16 +00:00
|
|
|
if(NOT (_PREFAST_ OR _VS_ANALYZE_))
|
2012-01-14 17:27:17 +00:00
|
|
|
add_compile_flags("/Zi")
|
|
|
|
endif()
|
|
|
|
add_compile_flags("/Ob0 /Od")
|
2012-08-27 18:58:27 +00:00
|
|
|
#elseif(${CMAKE_BUILD_TYPE} STREQUAL "Release")
|
|
|
|
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
|
2012-01-14 17:27:17 +00:00
|
|
|
add_compile_flags("/Ob2 /D NDEBUG")
|
|
|
|
endif()
|
|
|
|
|
2013-01-08 20:33:08 +00:00
|
|
|
if(MSVC_IDE)
|
|
|
|
add_compile_flags("/MP")
|
2013-08-28 21:37:54 +00:00
|
|
|
if(NOT DEFINED USE_FOLDER_STRUCTURE)
|
|
|
|
set(USE_FOLDER_STRUCTURE FALSE)
|
|
|
|
endif()
|
2011-05-16 13:12:07 +00:00
|
|
|
endif()
|
|
|
|
|
2014-10-12 22:59:32 +00:00
|
|
|
if(NOT DEFINED RUNTIME_CHECKS)
|
|
|
|
set(RUNTIME_CHECKS FALSE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(RUNTIME_CHECKS)
|
|
|
|
add_definitions(-D__RUNTIME_CHECKS__)
|
2014-10-18 14:22:09 +00:00
|
|
|
add_compile_flags("/RTC1")
|
2014-10-12 22:59:32 +00:00
|
|
|
endif()
|
|
|
|
|
2013-09-22 21:04:06 +00:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO /INCREMENTAL:NO /SAFESEH:NO /NODEFAULTLIB /RELEASE")
|
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /MANIFEST:NO /INCREMENTAL:NO /SAFESEH:NO /NODEFAULTLIB /RELEASE")
|
|
|
|
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /MANIFEST:NO /INCREMENTAL:NO /SAFESEH:NO /NODEFAULTLIB /RELEASE")
|
2011-06-11 16:09:57 +00:00
|
|
|
|
2014-02-12 19:36:19 +00:00
|
|
|
if(CMAKE_DISABLE_NINJA_DEPSLOG)
|
|
|
|
set(cl_includes_flag "")
|
|
|
|
else()
|
|
|
|
set(cl_includes_flag "/showIncludes")
|
|
|
|
endif()
|
|
|
|
|
2013-01-08 20:33:08 +00:00
|
|
|
if(MSVC_IDE AND (CMAKE_VERSION MATCHES "ReactOS"))
|
2014-03-24 20:54:01 +00:00
|
|
|
# For VS builds we'll only have en-US in resource files
|
2013-01-08 20:33:08 +00:00
|
|
|
add_definitions(/DLANGUAGE_EN_US)
|
2011-06-14 15:28:16 +00:00
|
|
|
else()
|
2014-03-24 20:54:01 +00:00
|
|
|
# Only VS 10+ resource compiler supports /nologo
|
|
|
|
if(MSVC_VERSION GREATER 1599)
|
|
|
|
set(rc_nologo_flag "/nologo")
|
|
|
|
else()
|
|
|
|
set(rc_nologo_flag)
|
|
|
|
endif()
|
|
|
|
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> ${rc_nologo_flag} <FLAGS> <DEFINES> ${I18N_DEFS} /fo<OBJECT> <SOURCE>")
|
2014-05-26 15:28:12 +00:00
|
|
|
if(ARCH STREQUAL "arm")
|
|
|
|
set(CMAKE_ASM_COMPILE_OBJECT
|
|
|
|
"cl ${cl_includes_flag} /nologo /X /I${REACTOS_SOURCE_DIR}/include/asm /I${REACTOS_BINARY_DIR}/include/asm <FLAGS> <DEFINES> /D__ASM__ /D_USE_ML /EP /c <SOURCE> > <OBJECT>.tmp"
|
|
|
|
"<CMAKE_ASM_COMPILER> -nologo -o <OBJECT> <OBJECT>.tmp")
|
|
|
|
else()
|
|
|
|
set(CMAKE_ASM_COMPILE_OBJECT
|
|
|
|
"cl ${cl_includes_flag} /nologo /X /I${REACTOS_SOURCE_DIR}/include/asm /I${REACTOS_BINARY_DIR}/include/asm <FLAGS> <DEFINES> /D__ASM__ /D_USE_ML /EP /c <SOURCE> > <OBJECT>.tmp"
|
|
|
|
"<CMAKE_ASM_COMPILER> /nologo /Cp /Fo<OBJECT> /c /Ta <OBJECT>.tmp")
|
|
|
|
endif()
|
2011-06-14 15:28:16 +00:00
|
|
|
endif()
|
2011-06-11 16:09:57 +00:00
|
|
|
|
2012-05-10 10:39:16 +00:00
|
|
|
if(_VS_ANALYZE_)
|
|
|
|
message("VS static analysis enabled!")
|
|
|
|
add_compile_flags("/analyze")
|
|
|
|
elseif(_PREFAST_)
|
|
|
|
message("PREFAST enabled!")
|
2012-08-24 15:36:17 +00:00
|
|
|
set(CMAKE_C_COMPILE_OBJECT "prefast <CMAKE_C_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO} <FLAGS> <DEFINES> /Fo<OBJECT> -c <SOURCE>${CMAKE_END_TEMP_FILE}"
|
2012-01-07 21:50:10 +00:00
|
|
|
"prefast LIST")
|
2012-08-24 15:36:17 +00:00
|
|
|
set(CMAKE_CXX_COMPILE_OBJECT "prefast <CMAKE_CXX_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO} <FLAGS> <DEFINES> /TP /Fo<OBJECT> -c <SOURCE>${CMAKE_END_TEMP_FILE}"
|
2012-01-07 21:50:10 +00:00
|
|
|
"prefast LIST")
|
2012-05-10 10:39:16 +00:00
|
|
|
set(CMAKE_C_LINK_EXECUTABLE
|
2012-08-24 15:36:17 +00:00
|
|
|
"<CMAKE_C_COMPILER> ${CMAKE_CL_NOLOGO} <OBJECTS> ${CMAKE_START_TEMP_FILE} <FLAGS> /Fe<TARGET> -link /implib:<TARGET_IMPLIB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>${CMAKE_END_TEMP_FILE}")
|
2012-05-10 10:39:16 +00:00
|
|
|
set(CMAKE_CXX_LINK_EXECUTABLE
|
2012-08-24 15:36:17 +00:00
|
|
|
"<CMAKE_CXX_COMPILER> ${CMAKE_CL_NOLOGO} <OBJECTS> ${CMAKE_START_TEMP_FILE} <FLAGS> /Fe<TARGET> -link /implib:<TARGET_IMPLIB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>${CMAKE_END_TEMP_FILE}")
|
2012-01-05 17:19:15 +00:00
|
|
|
endif()
|
|
|
|
|
2011-05-16 13:12:07 +00:00
|
|
|
set(CMAKE_RC_CREATE_SHARED_LIBRARY ${CMAKE_C_CREATE_SHARED_LIBRARY})
|
|
|
|
set(CMAKE_ASM_CREATE_SHARED_LIBRARY ${CMAKE_C_CREATE_SHARED_LIBRARY})
|
2011-06-11 16:09:57 +00:00
|
|
|
set(CMAKE_ASM_CREATE_STATIC_LIBRARY ${CMAKE_C_CREATE_STATIC_LIBRARY})
|
2011-05-16 13:12:07 +00:00
|
|
|
|
2014-02-12 19:55:12 +00:00
|
|
|
if(PCH)
|
|
|
|
macro(add_pch _target _pch _sources)
|
2014-02-23 12:25:36 +00:00
|
|
|
|
|
|
|
# Workaround for the MSVC toolchain (MSBUILD) /MP bug
|
|
|
|
set(_temp_gch ${CMAKE_CURRENT_BINARY_DIR}/${_target}.pch)
|
|
|
|
if(MSVC_IDE)
|
|
|
|
file(TO_NATIVE_PATH ${_temp_gch} _gch)
|
|
|
|
else()
|
|
|
|
set(_gch ${_temp_gch})
|
|
|
|
endif()
|
2014-02-12 19:55:12 +00:00
|
|
|
|
|
|
|
if(IS_CPP)
|
|
|
|
set(_pch_language CXX)
|
|
|
|
set(_cl_lang_flag "/TP")
|
|
|
|
else()
|
|
|
|
set(_pch_language C)
|
|
|
|
set(_cl_lang_flag "/TC")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(MSVC_IDE)
|
|
|
|
set(_pch_path_name_flag "/Fp${_gch}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Build the precompiled header
|
|
|
|
# HEADER_FILE_ONLY FALSE: force compiling the header
|
|
|
|
set_source_files_properties(${_pch} PROPERTIES
|
|
|
|
HEADER_FILE_ONLY FALSE
|
|
|
|
LANGUAGE ${_pch_language}
|
|
|
|
COMPILE_FLAGS "${_cl_lang_flag} /Yc /Fp${_gch}"
|
|
|
|
OBJECT_OUTPUTS ${_gch})
|
|
|
|
|
|
|
|
# Prevent a race condition related to writing to the PDB files between the PCH and the excluded list of source files
|
|
|
|
get_target_property(_target_sources ${_target} SOURCES)
|
|
|
|
list(REMOVE_ITEM _target_sources ${_pch})
|
|
|
|
foreach(_target_src ${_target_sources})
|
|
|
|
set_property(SOURCE ${_target_src} APPEND PROPERTY OBJECT_DEPENDS ${_gch})
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
# Use the precompiled header with the specified source files, skipping the pch itself
|
|
|
|
list(REMOVE_ITEM ${_sources} ${_pch})
|
|
|
|
foreach(_src ${${_sources}})
|
|
|
|
set_property(SOURCE ${_src} APPEND_STRING PROPERTY COMPILE_FLAGS " /FI${_gch} /Yu${_gch} ${_pch_path_name_flag}")
|
|
|
|
endforeach()
|
|
|
|
endmacro()
|
|
|
|
else()
|
2014-02-12 22:12:52 +00:00
|
|
|
macro(add_pch _target _pch _sources)
|
2014-02-12 19:55:12 +00:00
|
|
|
endmacro()
|
|
|
|
endif()
|
2011-05-16 13:12:07 +00:00
|
|
|
|
2011-08-20 12:29:51 +00:00
|
|
|
function(set_entrypoint _module _entrypoint)
|
|
|
|
if(${_entrypoint} STREQUAL "0")
|
2011-09-03 14:57:27 +00:00
|
|
|
add_target_link_flags(${_module} "/NOENTRY")
|
2012-08-27 18:58:27 +00:00
|
|
|
elseif(ARCH STREQUAL "i386")
|
2011-08-20 12:29:51 +00:00
|
|
|
set(_entrysymbol ${_entrypoint})
|
2011-10-02 18:59:33 +00:00
|
|
|
if(${ARGC} GREATER 2)
|
2011-08-20 12:29:51 +00:00
|
|
|
set(_entrysymbol ${_entrysymbol}@${ARGV2})
|
|
|
|
endif()
|
2011-09-03 14:57:27 +00:00
|
|
|
add_target_link_flags(${_module} "/ENTRY:${_entrysymbol}")
|
2011-05-16 13:12:07 +00:00
|
|
|
else()
|
2011-09-03 14:57:27 +00:00
|
|
|
add_target_link_flags(${_module} "/ENTRY:${_entrypoint}")
|
2011-05-16 13:12:07 +00:00
|
|
|
endif()
|
2011-08-08 11:54:20 +00:00
|
|
|
endfunction()
|
2011-05-16 13:12:07 +00:00
|
|
|
|
2011-08-08 11:54:20 +00:00
|
|
|
function(set_subsystem MODULE SUBSYSTEM)
|
2014-01-22 22:46:30 +00:00
|
|
|
if(ARCH STREQUAL "amd64")
|
|
|
|
add_target_link_flags(${MODULE} "/SUBSYSTEM:${SUBSYSTEM},5.02")
|
2013-08-28 12:32:09 +00:00
|
|
|
else()
|
2014-01-22 22:46:30 +00:00
|
|
|
add_target_link_flags(${MODULE} "/SUBSYSTEM:${SUBSYSTEM},5.01")
|
2013-08-28 12:32:09 +00:00
|
|
|
endif()
|
2011-08-08 11:54:20 +00:00
|
|
|
endfunction()
|
2011-05-16 13:12:07 +00:00
|
|
|
|
2011-08-08 11:54:20 +00:00
|
|
|
function(set_image_base MODULE IMAGE_BASE)
|
2011-09-03 14:57:27 +00:00
|
|
|
add_target_link_flags(${MODULE} "/BASE:${IMAGE_BASE}")
|
2011-08-08 11:54:20 +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)
|
2013-06-22 14:44:56 +00:00
|
|
|
if(CPP_USE_STL)
|
|
|
|
if((${TYPE} STREQUAL "kernelmodedriver") OR (${TYPE} STREQUAL "wdmdriver"))
|
|
|
|
message(FATAL_ERROR "Use of STL in kernelmodedriver or wdmdriver type module prohibited")
|
|
|
|
endif()
|
2013-06-22 15:57:36 +00:00
|
|
|
target_link_libraries(${MODULE} cpprt stlport oldnames)
|
|
|
|
elseif(CPP_USE_RT)
|
|
|
|
target_link_libraries(${MODULE} cpprt)
|
2013-06-22 14:44:56 +00:00
|
|
|
endif()
|
2012-08-27 18:58:27 +00:00
|
|
|
if((${TYPE} STREQUAL "win32dll") OR (${TYPE} STREQUAL "win32ocx") OR (${TYPE} STREQUAL "cpl"))
|
2011-09-03 14:57:27 +00:00
|
|
|
add_target_link_flags(${MODULE} "/DLL")
|
2012-08-27 18:58:27 +00:00
|
|
|
elseif(${TYPE} STREQUAL "kernelmodedriver")
|
2011-09-03 14:57:27 +00:00
|
|
|
add_target_link_flags(${MODULE} "/DRIVER")
|
2013-04-02 08:08:36 +00:00
|
|
|
elseif(${TYPE} STREQUAL "wdmdriver")
|
|
|
|
add_target_link_flags(${MODULE} "/DRIVER:WDM")
|
2011-05-16 13:12:07 +00:00
|
|
|
endif()
|
2014-10-18 14:22:09 +00:00
|
|
|
|
|
|
|
if(RUNTIME_CHECKS)
|
|
|
|
target_link_libraries(${MODULE} runtmchk)
|
|
|
|
endif()
|
|
|
|
|
2011-08-08 11:54:20 +00:00
|
|
|
endfunction()
|
2011-05-16 13:12:07 +00:00
|
|
|
|
2014-03-24 20:54:01 +00:00
|
|
|
# Define those for having real libraries
|
2012-02-21 14:32:05 +00:00
|
|
|
set(CMAKE_IMPLIB_CREATE_STATIC_LIBRARY "LINK /LIB /NOLOGO <LINK_FLAGS> /OUT:<TARGET> <OBJECTS>")
|
2014-05-26 15:28:12 +00:00
|
|
|
|
|
|
|
if(ARCH STREQUAL "arm")
|
|
|
|
set(CMAKE_STUB_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> -nologo -o <OBJECT> <SOURCE>")
|
|
|
|
else()
|
|
|
|
set(CMAKE_STUB_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> /nologo /Cp /Fo<OBJECT> /c /Ta <SOURCE>")
|
|
|
|
endif()
|
|
|
|
|
2013-07-14 11:44:21 +00:00
|
|
|
function(add_delay_importlibs _module)
|
|
|
|
get_target_property(_module_type ${_module} TYPE)
|
|
|
|
if(_module_type STREQUAL "STATIC_LIBRARY")
|
|
|
|
message(FATAL_ERROR "Cannot add delay imports to a static library")
|
|
|
|
endif()
|
2013-07-14 21:00:42 +00:00
|
|
|
foreach(_lib ${ARGN})
|
|
|
|
add_target_link_flags(${_module} "/DELAYLOAD:${_lib}.dll")
|
|
|
|
target_link_libraries(${_module} lib${_lib})
|
2011-08-11 13:39:06 +00:00
|
|
|
endforeach()
|
2013-07-14 11:44:21 +00:00
|
|
|
target_link_libraries(${_module} delayimp)
|
|
|
|
endfunction()
|
2011-06-10 20:44:47 +00:00
|
|
|
|
2012-04-29 19:04:02 +00:00
|
|
|
function(generate_import_lib _libname _dllname _spec_file)
|
2012-08-06 20:29:38 +00:00
|
|
|
|
|
|
|
set(_def_file ${CMAKE_CURRENT_BINARY_DIR}/${_libname}_exp.def)
|
|
|
|
set(_asm_stubs_file ${CMAKE_CURRENT_BINARY_DIR}/${_libname}_stubs.asm)
|
2013-09-22 21:04:06 +00:00
|
|
|
|
2012-04-29 19:04:02 +00:00
|
|
|
# Generate the asm stub file and the def file for import library
|
|
|
|
add_custom_command(
|
2012-08-06 20:29:38 +00:00
|
|
|
OUTPUT ${_asm_stubs_file} ${_def_file}
|
2013-11-17 22:11:04 +00:00
|
|
|
COMMAND native-spec2def --ms -a=${SPEC2DEF_ARCH} --implib -n=${_dllname} -d=${_def_file} -l=${_asm_stubs_file} ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file}
|
2012-04-29 19:04:02 +00:00
|
|
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file} native-spec2def)
|
2013-09-22 21:04:06 +00:00
|
|
|
|
2012-08-06 20:29:38 +00:00
|
|
|
if(MSVC_IDE)
|
|
|
|
# Compile the generated asm stub file
|
2014-05-26 15:28:12 +00:00
|
|
|
if(ARCH STREQUAL "arm")
|
|
|
|
set(_asm_stub_command ${CMAKE_ASM_COMPILER} -nologo -o ${_asm_stubs_file}.obj ${_asm_stubs_file})
|
|
|
|
else()
|
|
|
|
set(_asm_stub_command ${CMAKE_ASM_COMPILER} /Cp /Fo${_asm_stubs_file}.obj /c /Ta ${_asm_stubs_file})
|
|
|
|
endif()
|
2012-08-06 20:29:38 +00:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${_asm_stubs_file}.obj
|
2014-05-26 15:28:12 +00:00
|
|
|
COMMAND ${_asm_stub_command}
|
2012-08-06 20:29:38 +00:00
|
|
|
DEPENDS ${_asm_stubs_file})
|
|
|
|
else()
|
2014-03-24 20:54:01 +00:00
|
|
|
# Be clear about the "language"
|
2012-08-06 20:29:38 +00:00
|
|
|
# Thanks MS for creating a stupid linker
|
|
|
|
set_source_files_properties(${_asm_stubs_file} PROPERTIES LANGUAGE "STUB_ASM")
|
|
|
|
endif()
|
2012-04-29 19:04:02 +00:00
|
|
|
|
2014-03-24 20:54:01 +00:00
|
|
|
# Add our library
|
2012-08-06 20:29:38 +00:00
|
|
|
if(MSVC_IDE)
|
|
|
|
add_library(${_libname} STATIC EXCLUDE_FROM_ALL ${_asm_stubs_file}.obj)
|
|
|
|
set_source_files_properties(${_asm_stubs_file}.obj PROPERTIES EXTERNAL_OBJECT 1)
|
|
|
|
set_target_properties(${_libname} PROPERTIES LINKER_LANGUAGE "C")
|
|
|
|
else()
|
|
|
|
# NOTE: as stub file and def file are generated in one pass, depending on one is like depending on the other
|
|
|
|
add_library(${_libname} STATIC EXCLUDE_FROM_ALL ${_asm_stubs_file})
|
|
|
|
# set correct "link rule"
|
|
|
|
set_target_properties(${_libname} PROPERTIES LINKER_LANGUAGE "IMPLIB")
|
|
|
|
endif()
|
|
|
|
set_target_properties(${_libname} PROPERTIES STATIC_LIBRARY_FLAGS "/DEF:${_def_file}")
|
2012-04-29 19:04:02 +00:00
|
|
|
endfunction()
|
|
|
|
|
2012-08-27 18:58:27 +00:00
|
|
|
if(ARCH STREQUAL "amd64")
|
2014-05-27 21:32:42 +00:00
|
|
|
# This is NOT a typo.
|
|
|
|
# See https://software.intel.com/en-us/forums/topic/404643
|
|
|
|
add_definitions(/D__x86_64)
|
2012-03-07 21:21:27 +00:00
|
|
|
set(SPEC2DEF_ARCH x86_64)
|
2014-05-26 15:28:12 +00:00
|
|
|
elseif(ARCH STREQUAL "arm")
|
|
|
|
add_definitions(/D__arm__)
|
|
|
|
set(SPEC2DEF_ARCH arm)
|
2012-03-07 21:21:27 +00:00
|
|
|
else()
|
|
|
|
set(SPEC2DEF_ARCH i386)
|
|
|
|
endif()
|
2011-08-08 11:54:20 +00:00
|
|
|
function(spec2def _dllname _spec_file)
|
2014-03-24 20:54:01 +00:00
|
|
|
# Do we also want to add importlib targets?
|
2011-08-15 15:36:25 +00:00
|
|
|
if(${ARGC} GREATER 2)
|
2012-03-07 21:21:27 +00:00
|
|
|
if(${ARGN} STREQUAL "ADD_IMPORTLIB")
|
|
|
|
set(__add_importlib TRUE)
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Wrong argument passed to spec2def, ${ARGN}")
|
|
|
|
endif()
|
|
|
|
endif()
|
2012-04-20 12:39:00 +00:00
|
|
|
|
2014-03-24 20:54:01 +00:00
|
|
|
# Get library basename
|
2012-03-07 21:21:27 +00:00
|
|
|
get_filename_component(_file ${_dllname} NAME_WE)
|
2012-04-20 12:39:00 +00:00
|
|
|
|
2014-03-24 20:54:01 +00:00
|
|
|
# Error out on anything else than spec
|
2012-03-07 21:21:27 +00:00
|
|
|
if(NOT ${_spec_file} MATCHES ".*\\.spec")
|
|
|
|
message(FATAL_ERROR "spec2def only takes spec files as input.")
|
2011-08-15 15:36:25 +00:00
|
|
|
endif()
|
2012-04-20 12:39:00 +00:00
|
|
|
|
2014-03-24 20:54:01 +00:00
|
|
|
# Generate exports def and C stubs file for the DLL
|
2011-05-16 13:12:07 +00:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file}.def ${CMAKE_CURRENT_BINARY_DIR}/${_file}_stubs.c
|
2013-11-17 22:11:04 +00:00
|
|
|
COMMAND native-spec2def --ms -a=${SPEC2DEF_ARCH} -n=${_dllname} -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)
|
2012-03-31 21:52:09 +00:00
|
|
|
|
2012-04-29 19:04:02 +00:00
|
|
|
if(__add_importlib)
|
|
|
|
generate_import_lib(lib${_file} ${_dllname} ${_spec_file})
|
2012-03-07 21:21:27 +00:00
|
|
|
endif()
|
2011-08-08 11:54:20 +00:00
|
|
|
endfunction()
|
2011-05-16 13:12:07 +00:00
|
|
|
|
2011-10-03 19:09:26 +00:00
|
|
|
macro(macro_mc FLAG FILE)
|
2014-03-15 21:30:49 +00:00
|
|
|
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()
|
|
|
|
|
2014-03-24 20:54:01 +00:00
|
|
|
# PSEH workaround
|
2011-05-16 13:12:07 +00:00
|
|
|
set(PSEH_LIB "pseh")
|
2011-06-07 23:22:38 +00:00
|
|
|
|
2012-08-24 15:36:17 +00:00
|
|
|
# Use a full path for the x86 version of ml when using x64 VS.
|
|
|
|
# It's not a problem when using the DDK/WDK because, in x64 mode,
|
|
|
|
# both the x86 and x64 versions of ml are available.
|
2012-08-27 18:58:27 +00:00
|
|
|
if((ARCH STREQUAL "amd64") AND (DEFINED ENV{VCINSTALLDIR}))
|
2011-08-26 17:33:33 +00:00
|
|
|
set(CMAKE_ASM16_COMPILER $ENV{VCINSTALLDIR}/bin/ml.exe)
|
2014-05-26 15:28:12 +00:00
|
|
|
elseif(ARCH STREQUAL "arm")
|
|
|
|
set(CMAKE_ASM16_COMPILER armasm.exe)
|
2011-08-26 17:33:33 +00:00
|
|
|
else()
|
|
|
|
set(CMAKE_ASM16_COMPILER ml.exe)
|
|
|
|
endif()
|
|
|
|
|
2012-04-20 12:39:00 +00:00
|
|
|
function(CreateBootSectorTarget _target_name _asm_file _binary_file _base_address)
|
2011-06-07 23:22:38 +00:00
|
|
|
set(_object_file ${_binary_file}.obj)
|
|
|
|
set(_temp_file ${_binary_file}.tmp)
|
|
|
|
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${_temp_file}
|
2012-08-24 15:36:17 +00:00
|
|
|
COMMAND ${CMAKE_C_COMPILER} /nologo /X /I${REACTOS_SOURCE_DIR}/include/asm /I${REACTOS_BINARY_DIR}/include/asm /D__ASM__ /D_USE_ML /EP /c ${_asm_file} > ${_temp_file}
|
2011-06-07 23:22:38 +00:00
|
|
|
DEPENDS ${_asm_file})
|
|
|
|
|
2014-05-26 15:28:12 +00:00
|
|
|
if(ARCH STREQUAL "arm")
|
|
|
|
set(_asm16_command ${CMAKE_ASM16_COMPILER} -nologo -o ${_object_file} ${_temp_file})
|
|
|
|
else()
|
|
|
|
set(_asm16_command ${CMAKE_ASM16_COMPILER} /nologo /Cp /Fo${_object_file} /c /Ta ${_temp_file})
|
|
|
|
endif()
|
|
|
|
|
2011-06-07 23:22:38 +00:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${_object_file}
|
2014-05-26 15:28:12 +00:00
|
|
|
COMMAND ${_asm16_command}
|
2011-06-07 23:22:38 +00:00
|
|
|
DEPENDS ${_temp_file})
|
|
|
|
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${_binary_file}
|
|
|
|
COMMAND native-obj2bin ${_object_file} ${_binary_file} ${_base_address}
|
2011-08-05 20:40:40 +00:00
|
|
|
DEPENDS ${_object_file} native-obj2bin)
|
2011-06-07 23:22:38 +00:00
|
|
|
|
|
|
|
set_source_files_properties(${_object_file} ${_temp_file} ${_binary_file} PROPERTIES GENERATED TRUE)
|
|
|
|
|
|
|
|
add_custom_target(${_target_name} ALL DEPENDS ${_binary_file})
|
2011-08-08 11:54:20 +00:00
|
|
|
endfunction()
|
2011-09-11 00:44:13 +00:00
|
|
|
|
|
|
|
function(allow_warnings __module)
|
|
|
|
endfunction()
|
2013-01-08 20:33:08 +00:00
|
|
|
|
|
|
|
macro(add_asm_files _target)
|
|
|
|
if(MSVC_IDE AND (CMAKE_VERSION MATCHES "ReactOS"))
|
|
|
|
get_defines(_directory_defines)
|
|
|
|
get_includes(_directory_includes)
|
|
|
|
get_directory_property(_defines COMPILE_DEFINITIONS)
|
|
|
|
foreach(_source_file ${ARGN})
|
|
|
|
get_filename_component(_source_file_base_name ${_source_file} NAME_WE)
|
2014-02-23 10:37:31 +00:00
|
|
|
get_filename_component(_source_file_full_path ${_source_file} ABSOLUTE)
|
2013-01-08 20:33:08 +00:00
|
|
|
set(_preprocessed_asm_file ${CMAKE_CURRENT_BINARY_DIR}/asm/${_source_file_base_name}_${_target}.tmp)
|
|
|
|
set(_object_file ${CMAKE_CURRENT_BINARY_DIR}/asm/${_source_file_base_name}_${_target}.obj)
|
|
|
|
get_source_file_property(_defines_semicolon_list ${_source_file_full_path} COMPILE_DEFINITIONS)
|
|
|
|
unset(_source_file_defines)
|
|
|
|
foreach(_define ${_defines_semicolon_list})
|
|
|
|
if(NOT ${_define} STREQUAL "NOTFOUND")
|
|
|
|
list(APPEND _source_file_defines -D${_define})
|
|
|
|
endif()
|
|
|
|
endforeach()
|
2014-05-26 15:28:12 +00:00
|
|
|
if(ARCH STREQUAL "arm")
|
|
|
|
set(_pp_asm_compile_command ${CMAKE_ASM_COMPILER} -nologo -o ${_object_file} ${_preprocessed_asm_file})
|
|
|
|
else()
|
|
|
|
set(_pp_asm_compile_command ${CMAKE_ASM_COMPILER} /nologo /Cp /Fo${_object_file} /c /Ta ${_preprocessed_asm_file})
|
|
|
|
endif()
|
2013-01-08 20:33:08 +00:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${_preprocessed_asm_file} ${_object_file}
|
2014-05-26 15:28:12 +00:00
|
|
|
COMMAND cl /nologo /X /I${REACTOS_SOURCE_DIR}/include/asm /I${REACTOS_BINARY_DIR}/include/asm ${_directory_includes} ${_source_file_defines} ${_directory_defines} /D__ASM__ /D_USE_ML /EP /c ${_source_file_full_path} > ${_preprocessed_asm_file} && ${_pp_asm_compile_command}
|
2013-01-08 20:33:08 +00:00
|
|
|
DEPENDS ${_source_file_full_path})
|
|
|
|
set_source_files_properties(${_object_file} PROPERTIES EXTERNAL_OBJECT 1)
|
|
|
|
list(APPEND ${_target} ${_object_file})
|
|
|
|
endforeach()
|
|
|
|
else()
|
|
|
|
list(APPEND ${_target} ${ARGN})
|
|
|
|
endif()
|
|
|
|
endmacro()
|