[ROSTESTS] Skip some flaky test / do not count successes
[reactos.git] / CMakeLists.txt
index bcf4c18..73b4e69 100644 (file)
@@ -1,19 +1,9 @@
 
-cmake_minimum_required(VERSION 2.8.12)
+cmake_minimum_required(VERSION 3.2.1)
+cmake_policy(VERSION 3.2.1)
 
-if(POLICY CMP0017)
-    # Shadow cmake provided modules
-    cmake_policy(SET CMP0017 OLD)
-endif()
-
-if(POLICY CMP0026)
-    # Allow use of the LOCATION property
-    cmake_policy(SET CMP0026 OLD)
-endif()
-
-if(POLICY CMP0051)
-    # List TARGET_OBJECTS in SOURCES target property
-    cmake_policy(SET CMP0051 NEW)
+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()
 
 if(POLICY CMP0058)
@@ -21,30 +11,26 @@ if(POLICY CMP0058)
     cmake_policy(SET CMP0058 OLD)
 endif()
 
+if(POLICY CMP0065)
+    # Do not add flags to export symbols from executables without the ENABLE_EXPORTS target property
+    cmake_policy(SET CMP0065 NEW)
+endif()
+
 project(REACTOS)
 
 # Versioning
 include(sdk/include/reactos/version.cmake)
 
-# Don't escape preprocessor definition values added via add_definitions
-cmake_policy(SET CMP0005 OLD)
-cmake_policy(SET CMP0002 NEW)
-if(POLICY CMP0018)
-    cmake_policy(SET CMP0018 OLD)
-endif()
-
 set(CMAKE_INCLUDE_CURRENT_DIR ON)
 set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
 set(CMAKE_SHARED_LIBRARY_PREFIX "")
+set(CMAKE_SHARED_MODULE_PREFIX "")
 set(CMAKE_SKIP_PREPROCESSED_SOURCE_RULES TRUE)
 set(CMAKE_SKIP_ASSEMBLY_SOURCE_RULES TRUE)
 set(CMAKE_COLOR_MAKEFILE OFF)
+set(CMAKE_POSITION_INDEPENDENT_CODE OFF)
 #set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
 
-if(NOT DEFINED NEW_STYLE_BUILD)
-    set(NEW_STYLE_BUILD TRUE)
-endif()
-
 if(NOT ARCH)
     set(ARCH i386)
 endif()
@@ -69,30 +55,30 @@ include(sdk/cmake/compilerflags.cmake)
 
 add_definitions(-D__REACTOS__)
 
+# Double escape, since CMake unescapes before putting it on the command-line, where it's unescaped again by GCC/CL.
+add_definitions(-DREACTOS_SOURCE_DIR="${REACTOS_SOURCE_DIR}")
+add_definitions(-DREACTOS_BINARY_DIR="${REACTOS_BINARY_DIR}")
+
+# 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})
+add_compile_flags(-D__RELFILE__="&__FILE__[__FILE__[0] == '.' ? sizeof \\\"${_PATH_PREFIX}\\\" - 1 : sizeof REACTOS_SOURCE_DIR]")
+
 if(MSVC_IDE)
     add_compile_flags("/MP")
 endif()
 
-# We don't need CMake importlib handling.
-# FIXME: Remove the MSVC_IDE condition when the upcoming RosBE lands.
-if(NOT MSVC_IDE)
-    unset(CMAKE_IMPORT_LIBRARY_SUFFIX)
-endif()
-
 # Bison and Flex support
 # include(sdk/cmake/bison-flex.cmake)
 
 if(NOT CMAKE_CROSSCOMPILING)
-
-    if(NEW_STYLE_BUILD)
-        set(TOOLS_FOLDER ${CMAKE_CURRENT_BINARY_DIR})
-    endif()
-
+    set(TOOLS_FOLDER ${CMAKE_CURRENT_BINARY_DIR})
     add_definitions(-DTARGET_${ARCH})
 
     if(MSVC)
         if(ARCH STREQUAL "i386")
-            add_definitions(/D_X86_ /DWIN32 /D_WINDOWS)
+            add_definitions(/D_X86_ /D__i386__ /DWIN32 /D_WINDOWS)
+        elseif(ARCH STREQUAL "amd64")
+            add_definitions(-D_AMD64_ -D__x86_64__ /DWIN32 -D_WINDOWS)
         endif()
         if(MSVC_VERSION GREATER 1699)
             add_definitions(/D_ALLOW_KEYWORD_MACROS)
@@ -102,8 +88,7 @@ if(NOT CMAKE_CROSSCOMPILING)
             add_definitions(/Dinline=__inline)
         endif()
     endif()
-
-    include_directories(sdk/include/host)
+    add_subdirectory(sdk/include/host)
 
     if(NOT MSVC)
         add_subdirectory(dll/win32/dbghelp)
@@ -111,19 +96,21 @@ if(NOT CMAKE_CROSSCOMPILING)
     add_subdirectory(sdk/tools)
     add_subdirectory(sdk/lib)
 
-    if(NOT NEW_STYLE_BUILD)
-        if(NOT MSVC)
-            export(TARGETS bin2c widl gendib cabman fatten hpp isohybrid mkhive mkisofs obj2bin spec2def geninc rsym mkshelllink utf16le xml2sdb FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
-        else()
-            export(TARGETS bin2c widl gendib cabman fatten hpp isohybrid mkhive mkisofs obj2bin spec2def geninc mkshelllink utf16le xml2sdb FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
-        endif()
+    set(NATIVE_TARGETS bin2c widl gendib cabman fatten hpp isohybrid mkhive mkisofs obj2bin spec2def geninc mkshelllink utf16le xml2sdb)
+    if(NOT MSVC)
+        list(APPEND NATIVE_TARGETS rsym)
     endif()
 
+    export(TARGETS ${NATIVE_TARGETS} FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
+    configure_file(sdk/cmake/host-tools.in ${CMAKE_BINARY_DIR}/TargetList.cmake)
+
 else()
+    # Add host tools target
+    include(sdk/cmake/host-tools.cmake)
+    setup_host_tools()
 
-    if(NEW_STYLE_BUILD)
-        include(sdk/cmake/host-tools.cmake)
-    endif()
+    # We don't need CMake importlib handling.
+    unset(CMAKE_IMPORT_LIBRARY_SUFFIX)
 
     # Print build type
     message("-- Build Type: ${CMAKE_BUILD_TYPE}")
@@ -138,24 +125,6 @@ else()
     #useful stuff!
     include(CMakeParseArguments)
 
-    # Do some cleanup
-    file(REMOVE
-        ${REACTOS_BINARY_DIR}/dependencies.graphml
-        ${REACTOS_BINARY_DIR}/boot/ros_livecd.txt
-        ${REACTOS_BINARY_DIR}/boot/ros_livecd_target.txt
-        ${REACTOS_BINARY_DIR}/boot/ros_minicd.txt
-        ${REACTOS_BINARY_DIR}/boot/ros_minicd_target.txt
-        ${REACTOS_BINARY_DIR}/boot/ros_cab.txt
-        ${REACTOS_BINARY_DIR}/boot/ros_cab_target.txt)
-
-    if(NOT NEW_STYLE_BUILD)
-        if(NOT DEFINED REACTOS_BUILD_TOOLS_DIR)
-            set(REACTOS_BUILD_TOOLS_DIR ${REACTOS_SOURCE_DIR}/build)
-        endif()
-        set(IMPORT_EXECUTABLES "${REACTOS_BUILD_TOOLS_DIR}/ImportExecutables.cmake" CACHE FILEPATH "Host executables")
-        include(${IMPORT_EXECUTABLES})
-    endif()
-
     if(DBG)
         add_definitions(-DDBG=1 -D_SEH_ENABLE_TRACE)
     else()
@@ -163,11 +132,11 @@ else()
     endif()
 
     if(KDBG)
-        add_definitions(-DKDBG=1)
+        add_definitions(-DKDBG)
     endif()
 
     if(_WINKD_)
-        add_definitions(-D_WINKD_=1)
+        add_definitions(-D_WINKD_)
     endif()
 
     if(CMAKE_VERSION MATCHES "ReactOS")
@@ -181,7 +150,8 @@ else()
                     -D_WIN32_IE=0x600
                     -D_WIN32_WINNT=0x502
                     -D_WIN32_WINDOWS=0x502
-                    -D_SETUPAPI_VER=0x502)
+                    -D_SETUPAPI_VER=0x502
+                    -DMINGW_HAS_SECURE_API=1)
 
     # Arch Options
     if(ARCH STREQUAL "i386")
@@ -200,6 +170,7 @@ else()
     endif()
 
     # Other
+    add_definitions(-D_NEW_DELETE_OPERATORS_)
     if(ARCH STREQUAL "i386")
         add_definitions(-DUSE_COMPILER_EXCEPTIONS -D_USE_32BIT_TIME_T)
     elseif(ARCH STREQUAL "amd64")