2011-05-16 21:12:07 +08:00
|
|
|
|
2020-06-07 04:59:26 +08:00
|
|
|
cmake_minimum_required(VERSION 3.17.0)
|
2011-05-16 21:12:07 +08:00
|
|
|
|
2018-05-11 11:57:10 +08:00
|
|
|
if(NOT CMAKE_VERSION MATCHES "ReactOS")
|
|
|
|
message(WARNING "Building with \"${CMAKE_COMMAND}\", which is not the custom CMake included in RosBE, might cause build issues...")
|
|
|
|
endif()
|
|
|
|
|
2011-05-16 21:12:07 +08:00
|
|
|
project(REACTOS)
|
|
|
|
|
2011-06-13 18:36:40 +08:00
|
|
|
# Versioning
|
2016-04-20 20:36:25 +08:00
|
|
|
include(sdk/include/reactos/version.cmake)
|
2011-05-16 21:12:07 +08:00
|
|
|
|
|
|
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|
|
|
set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
|
|
|
|
set(CMAKE_SHARED_LIBRARY_PREFIX "")
|
2019-03-20 21:19:48 +08:00
|
|
|
set(CMAKE_SHARED_MODULE_PREFIX "")
|
2011-05-16 21:12:07 +08:00
|
|
|
set(CMAKE_SKIP_PREPROCESSED_SOURCE_RULES TRUE)
|
|
|
|
set(CMAKE_SKIP_ASSEMBLY_SOURCE_RULES TRUE)
|
|
|
|
set(CMAKE_COLOR_MAKEFILE OFF)
|
2019-04-27 17:33:37 +08:00
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE OFF)
|
2011-05-16 21:12:07 +08:00
|
|
|
#set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
|
|
|
|
|
|
|
|
if(NOT ARCH)
|
|
|
|
set(ARCH i386)
|
|
|
|
endif()
|
2012-08-28 02:58:27 +08:00
|
|
|
# Now the ARCH variable will be in lowercase.
|
|
|
|
# It is needed because STREQUAL comparison
|
|
|
|
# is case-sensitive.
|
|
|
|
# See http://cmake.3232098.n2.nabble.com/Case-insensitive-string-compare-td7580269.html
|
|
|
|
# for more information.
|
2011-05-16 21:12:07 +08:00
|
|
|
string(TOLOWER ${ARCH} ARCH)
|
|
|
|
|
|
|
|
# Compile options
|
2012-08-28 02:58:27 +08:00
|
|
|
if(ARCH STREQUAL "i386")
|
2016-05-21 00:06:48 +08:00
|
|
|
include(sdk/cmake/config.cmake)
|
2012-08-28 02:58:27 +08:00
|
|
|
elseif(ARCH STREQUAL "amd64")
|
2016-05-21 00:06:48 +08:00
|
|
|
include(sdk/cmake/config-amd64.cmake)
|
2012-08-28 02:58:27 +08:00
|
|
|
elseif(ARCH STREQUAL "arm")
|
2016-05-21 00:06:48 +08:00
|
|
|
include(sdk/cmake/config-arm.cmake)
|
2011-05-16 21:12:07 +08:00
|
|
|
endif()
|
|
|
|
|
2011-06-13 18:36:40 +08:00
|
|
|
# Compiler flags handling
|
2016-05-21 00:06:48 +08:00
|
|
|
include(sdk/cmake/compilerflags.cmake)
|
2011-06-13 18:36:40 +08:00
|
|
|
|
2012-08-23 19:30:26 +08:00
|
|
|
add_definitions(-D__REACTOS__)
|
2018-12-10 00:51:50 +08:00
|
|
|
|
|
|
|
# There doesn't seem to be a standard for __FILE__ being relative or absolute, so detect it at runtime.
|
|
|
|
file(RELATIVE_PATH _PATH_PREFIX ${REACTOS_BINARY_DIR} ${REACTOS_SOURCE_DIR})
|
2020-09-18 22:19:46 +08:00
|
|
|
if (GCC AND (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "8.0.0"))
|
|
|
|
# Thankfully, GCC has this
|
|
|
|
add_compile_options(-ffile-prefix-map=${REACTOS_SOURCE_DIR}=)
|
|
|
|
add_compile_options(-ffile-prefix-map=${_PATH_PREFIX}=)
|
|
|
|
else()
|
|
|
|
string(LENGTH ${_PATH_PREFIX} _PATH_PREFIX_LENGTH)
|
|
|
|
string(LENGTH ${REACTOS_SOURCE_DIR} REACTOS_SOURCE_DIR_LENGTH)
|
|
|
|
math(EXPR REACTOS_SOURCE_DIR_LENGTH "${REACTOS_SOURCE_DIR_LENGTH} + 1")
|
|
|
|
add_compile_definitions("__RELFILE__=&__FILE__[__FILE__[0] == '.' ? ${_PATH_PREFIX_LENGTH} : ${REACTOS_SOURCE_DIR_LENGTH}]")
|
|
|
|
endif()
|
2011-05-16 21:12:07 +08:00
|
|
|
|
2015-05-12 19:38:32 +08:00
|
|
|
if(MSVC_IDE)
|
2020-09-21 18:16:02 +08:00
|
|
|
add_compile_options("/MP")
|
2015-05-12 19:38:32 +08:00
|
|
|
endif()
|
|
|
|
|
2015-08-28 07:00:49 +08:00
|
|
|
# Bison and Flex support
|
2016-05-21 00:06:48 +08:00
|
|
|
# include(sdk/cmake/bison-flex.cmake)
|
2015-08-28 07:00:49 +08:00
|
|
|
|
2011-05-16 21:12:07 +08:00
|
|
|
if(NOT CMAKE_CROSSCOMPILING)
|
2018-10-01 19:07:44 +08:00
|
|
|
set(TOOLS_FOLDER ${CMAKE_CURRENT_BINARY_DIR})
|
2011-05-16 21:12:07 +08:00
|
|
|
add_definitions(-DTARGET_${ARCH})
|
|
|
|
|
|
|
|
if(MSVC)
|
2012-08-28 02:58:27 +08:00
|
|
|
if(ARCH STREQUAL "i386")
|
2019-01-29 20:18:09 +08:00
|
|
|
add_definitions(/D_X86_ /D__i386__ /DWIN32 /D_WINDOWS)
|
2019-02-02 01:08:26 +08:00
|
|
|
elseif(ARCH STREQUAL "amd64")
|
|
|
|
add_definitions(-D_AMD64_ -D__x86_64__ /DWIN32 -D_WINDOWS)
|
2011-06-22 19:31:01 +08:00
|
|
|
endif()
|
2014-05-20 04:28:35 +08:00
|
|
|
if(MSVC_VERSION GREATER 1699)
|
2014-05-18 22:39:03 +08:00
|
|
|
add_definitions(/D_ALLOW_KEYWORD_MACROS)
|
|
|
|
endif()
|
2017-10-28 05:18:01 +08:00
|
|
|
if(NOT USE_CLANG_CL)
|
|
|
|
# FIXME: Inspect
|
|
|
|
add_definitions(/Dinline=__inline)
|
|
|
|
endif()
|
2011-05-16 21:12:07 +08:00
|
|
|
endif()
|
2019-11-15 21:07:46 +08:00
|
|
|
add_subdirectory(sdk/include/host)
|
2011-05-16 21:12:07 +08:00
|
|
|
|
2013-07-20 19:07:30 +08:00
|
|
|
if(NOT MSVC)
|
|
|
|
add_subdirectory(dll/win32/dbghelp)
|
|
|
|
endif()
|
2016-04-20 20:36:25 +08:00
|
|
|
add_subdirectory(sdk/tools)
|
|
|
|
add_subdirectory(sdk/lib)
|
2011-05-16 21:12:07 +08:00
|
|
|
|
2018-10-01 19:07:44 +08:00
|
|
|
set(NATIVE_TARGETS bin2c widl gendib cabman fatten hpp isohybrid mkhive mkisofs obj2bin spec2def geninc mkshelllink utf16le xml2sdb)
|
|
|
|
if(NOT MSVC)
|
2020-04-13 18:20:47 +08:00
|
|
|
list(APPEND NATIVE_TARGETS rsym pefixup)
|
2011-05-16 21:12:07 +08:00
|
|
|
endif()
|
|
|
|
|
2018-10-01 19:07:44 +08:00
|
|
|
export(TARGETS ${NATIVE_TARGETS} FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
|
|
|
|
configure_file(sdk/cmake/host-tools.in ${CMAKE_BINARY_DIR}/TargetList.cmake)
|
|
|
|
|
2011-05-16 21:12:07 +08:00
|
|
|
else()
|
2018-10-01 19:07:44 +08:00
|
|
|
# Add host tools target
|
|
|
|
include(sdk/cmake/host-tools.cmake)
|
|
|
|
setup_host_tools()
|
|
|
|
|
2018-05-25 18:59:47 +08:00
|
|
|
# We don't need CMake importlib handling.
|
|
|
|
unset(CMAKE_IMPORT_LIBRARY_SUFFIX)
|
2011-05-16 21:12:07 +08:00
|
|
|
|
2015-10-30 17:55:58 +08:00
|
|
|
# Print build type
|
|
|
|
message("-- Build Type: ${CMAKE_BUILD_TYPE}")
|
|
|
|
|
2011-05-16 21:12:07 +08:00
|
|
|
# adjust the default behaviour of the FIND_XXX() commands:
|
|
|
|
# search headers and libraries in the target environment, search
|
|
|
|
# programs in the host environment
|
|
|
|
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
|
|
|
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
|
|
|
|
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
|
2011-06-08 07:22:38 +08:00
|
|
|
|
2020-09-18 15:34:18 +08:00
|
|
|
# Add our own target properties
|
|
|
|
# C++
|
|
|
|
define_property(TARGET PROPERTY WITH_CXX_EXCEPTIONS
|
|
|
|
BRIEF_DOCS "Enable C++ exceptions on this target"
|
|
|
|
FULL_DOCS [[
|
|
|
|
Enables C++ exception handling.
|
|
|
|
Enable this if the module uses try/catch or throw. You might also need this if you use a standard operator new (the one without nothrow).]])
|
|
|
|
define_property(TARGET PROPERTY WITH_CXX_RTTI
|
|
|
|
BRIEF_DOCS "Enable C++ RTTI on this target"
|
|
|
|
FULL_DOCS [[
|
|
|
|
Enables run-time type information.
|
|
|
|
Enable this if the module uses typeid or dynamic_cast. You will probably need to link yith cpprt as well, if you are not already using STL.]])
|
|
|
|
|
|
|
|
|
2011-05-16 21:12:07 +08:00
|
|
|
if(DBG)
|
|
|
|
add_definitions(-DDBG=1 -D_SEH_ENABLE_TRACE)
|
2012-03-08 17:20:31 +08:00
|
|
|
else()
|
2012-03-08 17:18:28 +08:00
|
|
|
add_definitions(-DDBG=0)
|
2011-05-16 21:12:07 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(KDBG)
|
2019-08-18 00:20:51 +08:00
|
|
|
add_definitions(-DKDBG)
|
2011-05-16 21:12:07 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(_WINKD_)
|
2019-08-18 00:20:51 +08:00
|
|
|
add_definitions(-D_WINKD_)
|
2011-05-16 21:12:07 +08:00
|
|
|
endif()
|
|
|
|
|
2020-05-10 05:37:40 +08:00
|
|
|
if(ENABLE_CCACHE)
|
|
|
|
message(WARNING "-- Disabling precompiled headers support (ccache).")
|
|
|
|
option(PCH "Whether to use precompiled headers" OFF)
|
|
|
|
elseif(GCC)
|
|
|
|
message(WARNING "-- Disabling precompiled headers on GCC by default CORE-17108.")
|
|
|
|
option(PCH "Whether to use precompiled headers" OFF)
|
2014-02-14 05:42:05 +08:00
|
|
|
else()
|
2020-05-10 05:37:40 +08:00
|
|
|
option(PCH "Whether to use precompiled headers" ON)
|
2014-02-14 05:42:05 +08:00
|
|
|
endif()
|
|
|
|
|
2011-05-16 21:12:07 +08:00
|
|
|
# Version Options
|
|
|
|
add_definitions(-DWINVER=0x502
|
|
|
|
-D_WIN32_IE=0x600
|
|
|
|
-D_WIN32_WINNT=0x502
|
|
|
|
-D_WIN32_WINDOWS=0x502
|
2019-04-29 15:56:29 +08:00
|
|
|
-D_SETUPAPI_VER=0x502
|
|
|
|
-DMINGW_HAS_SECURE_API=1)
|
2011-05-16 21:12:07 +08:00
|
|
|
|
|
|
|
# Arch Options
|
2012-08-28 02:58:27 +08:00
|
|
|
if(ARCH STREQUAL "i386")
|
2017-10-28 05:18:01 +08:00
|
|
|
if(NOT USE_CLANG_CL)
|
|
|
|
add_definitions(-D_M_IX86)
|
|
|
|
endif()
|
|
|
|
add_definitions(-D_X86_ -D__i386__ -Di386)
|
2020-01-15 05:15:18 +08:00
|
|
|
if(SARCH STREQUAL "xbox")
|
|
|
|
add_definitions(-DSARCH_XBOX)
|
2019-11-11 00:47:39 +08:00
|
|
|
elseif(SARCH STREQUAL "pc98")
|
|
|
|
add_definitions(-DSARCH_PC98)
|
2020-01-15 05:15:18 +08:00
|
|
|
endif()
|
2012-08-28 02:58:27 +08:00
|
|
|
elseif(ARCH STREQUAL "amd64")
|
2011-05-16 21:12:07 +08:00
|
|
|
add_definitions(-D_M_AMD64 -D_AMD64_ -D__x86_64__ -D_WIN64)
|
2012-08-28 02:58:27 +08:00
|
|
|
elseif(ARCH STREQUAL "arm")
|
2011-05-16 21:12:07 +08:00
|
|
|
# _M_ARM is already defined by toolchain
|
2015-05-15 06:30:56 +08:00
|
|
|
add_definitions(-D_ARM_ -D__arm__ -DWIN32)
|
2015-04-11 22:03:19 +08:00
|
|
|
if(SARCH STREQUAL "omap-zoom2")
|
|
|
|
add_definitions(-D_ZOOM2_)
|
|
|
|
endif()
|
2011-05-16 21:12:07 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Other
|
2019-05-25 18:22:04 +08:00
|
|
|
add_definitions(-D_NEW_DELETE_OPERATORS_)
|
2012-08-28 02:58:27 +08:00
|
|
|
if(ARCH STREQUAL "i386")
|
2011-05-16 21:12:07 +08:00
|
|
|
add_definitions(-DUSE_COMPILER_EXCEPTIONS -D_USE_32BIT_TIME_T)
|
2012-08-28 02:58:27 +08:00
|
|
|
elseif(ARCH STREQUAL "amd64")
|
2011-05-16 21:12:07 +08:00
|
|
|
add_definitions(-DUSE_COMPILER_EXCEPTIONS -DNO_UNDERSCORE_PREFIX)
|
2012-08-28 02:58:27 +08:00
|
|
|
elseif(ARCH STREQUAL "arm")
|
2015-04-11 22:03:19 +08:00
|
|
|
add_definitions(-DUSE_COMPILER_EXCEPTIONS -DNO_UNDERSCORE_PREFIX)
|
2011-05-16 21:12:07 +08:00
|
|
|
endif()
|
2012-03-29 22:45:46 +08:00
|
|
|
|
2011-09-04 07:05:09 +08:00
|
|
|
# Activate support for assembly source files
|
|
|
|
enable_language(ASM)
|
|
|
|
|
|
|
|
# Activate language support for resource files
|
|
|
|
enable_language(RC)
|
2011-05-16 21:12:07 +08:00
|
|
|
|
2012-02-28 06:46:20 +08:00
|
|
|
# Localization definitions
|
2016-05-21 00:06:48 +08:00
|
|
|
include(sdk/cmake/localization.cmake)
|
2012-02-28 06:46:20 +08:00
|
|
|
set(I18N_DEFS "")
|
|
|
|
# This will set I18N_DEFS for later use
|
|
|
|
set_i18n_language(${I18N_LANG})
|
|
|
|
|
2011-06-12 00:09:57 +08:00
|
|
|
# Compiler specific definitions and macros
|
|
|
|
if(MSVC)
|
2016-05-21 00:06:48 +08:00
|
|
|
include(sdk/cmake/msvc.cmake)
|
2011-06-12 00:09:57 +08:00
|
|
|
else()
|
2016-05-21 00:06:48 +08:00
|
|
|
include(sdk/cmake/gcc.cmake)
|
2011-06-12 00:09:57 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Generic macros
|
2016-05-21 00:06:48 +08:00
|
|
|
include(sdk/cmake/CMakeMacros.cmake)
|
2011-06-12 00:09:57 +08:00
|
|
|
|
|
|
|
# IDL macros for widl/midl
|
2012-08-02 07:25:06 +08:00
|
|
|
# We're using widl now for both MSVC and GCC builds
|
2016-05-21 00:06:48 +08:00
|
|
|
include(sdk/cmake/widl-support.cmake)
|
2011-06-12 00:09:57 +08:00
|
|
|
|
2013-07-15 05:00:42 +08:00
|
|
|
include_directories(
|
2016-04-20 20:36:25 +08:00
|
|
|
sdk/include
|
|
|
|
sdk/include/psdk
|
|
|
|
sdk/include/dxsdk
|
|
|
|
${REACTOS_BINARY_DIR}/sdk/include
|
|
|
|
${REACTOS_BINARY_DIR}/sdk/include/psdk
|
|
|
|
${REACTOS_BINARY_DIR}/sdk/include/dxsdk
|
|
|
|
${REACTOS_BINARY_DIR}/sdk/include/ddk
|
|
|
|
${REACTOS_BINARY_DIR}/sdk/include/reactos
|
2016-09-29 07:20:20 +08:00
|
|
|
${REACTOS_BINARY_DIR}/sdk/include/reactos/mc
|
2016-04-20 20:36:25 +08:00
|
|
|
sdk/include/crt
|
|
|
|
sdk/include/ddk
|
|
|
|
sdk/include/ndk
|
|
|
|
sdk/include/reactos
|
|
|
|
sdk/include/reactos/libs)
|
2011-05-16 21:12:07 +08:00
|
|
|
|
2012-08-28 02:58:27 +08:00
|
|
|
if(ARCH STREQUAL "arm")
|
2016-04-20 20:36:25 +08:00
|
|
|
include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/arm)
|
2011-05-16 21:12:07 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
add_dependency_header()
|
|
|
|
|
2017-08-16 14:41:41 +08:00
|
|
|
add_subdirectory(sdk/include/ndk/tests)
|
2016-04-20 20:36:25 +08:00
|
|
|
add_subdirectory(sdk/include/xdk)
|
|
|
|
add_subdirectory(sdk/include/psdk)
|
|
|
|
add_subdirectory(sdk/include/dxsdk)
|
|
|
|
add_subdirectory(sdk/include/reactos/wine)
|
|
|
|
add_subdirectory(sdk/include/reactos/mc)
|
|
|
|
add_subdirectory(sdk/include/asm)
|
2011-05-16 21:12:07 +08:00
|
|
|
|
2014-10-11 21:36:08 +08:00
|
|
|
if(NO_ROSSYM)
|
2016-05-21 00:06:48 +08:00
|
|
|
include(sdk/cmake/baseaddress_dwarf.cmake)
|
2015-08-28 06:35:06 +08:00
|
|
|
elseif(MSVC)
|
2018-02-05 03:12:23 +08:00
|
|
|
if (ARCH STREQUAL "amd64")
|
|
|
|
include(sdk/cmake/baseaddress_msvc_x64.cmake)
|
|
|
|
else()
|
|
|
|
include(sdk/cmake/baseaddress_msvc.cmake)
|
|
|
|
endif()
|
2014-10-11 21:36:08 +08:00
|
|
|
else()
|
2016-05-21 00:06:48 +08:00
|
|
|
include(sdk/cmake/baseaddress.cmake)
|
2014-10-11 21:36:08 +08:00
|
|
|
endif()
|
2013-07-15 05:00:42 +08:00
|
|
|
|
2013-06-06 01:57:13 +08:00
|
|
|
# For MSVC builds, this puts all debug symbols file in the same directory.
|
2020-05-27 02:24:02 +08:00
|
|
|
if(MSVC)
|
2020-03-20 18:30:33 +08:00
|
|
|
set(CMAKE_PDB_OUTPUT_DIRECTORY "${REACTOS_BINARY_DIR}/msvc_pdb")
|
|
|
|
elseif(SEPARATE_DBG)
|
|
|
|
set(CMAKE_PDB_OUTPUT_DIRECTORY "${REACTOS_BINARY_DIR}/symbols")
|
|
|
|
endif()
|
2011-05-16 21:12:07 +08:00
|
|
|
|
|
|
|
#begin with boot so reactos_cab target is defined before all other modules
|
|
|
|
add_subdirectory(boot)
|
|
|
|
add_subdirectory(base)
|
|
|
|
add_subdirectory(dll)
|
|
|
|
add_subdirectory(drivers)
|
|
|
|
add_subdirectory(hal)
|
2016-04-20 20:36:25 +08:00
|
|
|
add_subdirectory(sdk/lib)
|
2011-05-16 21:12:07 +08:00
|
|
|
add_subdirectory(media)
|
|
|
|
add_subdirectory(modules)
|
|
|
|
add_subdirectory(ntoskrnl)
|
|
|
|
add_subdirectory(subsystems)
|
2016-04-20 20:36:25 +08:00
|
|
|
add_subdirectory(sdk/tools/wpp)
|
2012-04-02 01:27:38 +08:00
|
|
|
add_subdirectory(win32ss)
|
2011-05-16 21:12:07 +08:00
|
|
|
|
2015-03-29 19:38:05 +08:00
|
|
|
# Create the registry hives
|
|
|
|
create_registry_hives()
|
|
|
|
|
2020-09-06 10:35:33 +08:00
|
|
|
# Create {bootcd, livecd, bootcdregtest}.lst
|
|
|
|
create_iso_lists()
|
|
|
|
|
2016-04-20 20:36:25 +08:00
|
|
|
file(MAKE_DIRECTORY ${REACTOS_BINARY_DIR}/sdk/include/reactos)
|
2011-05-16 21:12:07 +08:00
|
|
|
|
|
|
|
add_dependency_footer()
|
|
|
|
endif()
|