From 72ad37c1cd437c3ef433c01edd4aab2957bea656 Mon Sep 17 00:00:00 2001 From: Victor Perevertkin Date: Tue, 13 Apr 2021 21:08:04 +0300 Subject: [PATCH] [CMAKE] Unify configs for architectures config*.cmake files are constantly getting out of sync between each other. Besides that, the parameters are not really dependent on a target architecture, but rather on a compiler (except *ARCH) This approach seems to be more future-prone, and allows to see all the options in one file (there are really not that many of them) --- CMakeLists.txt | 8 +---- sdk/cmake/config-amd64.cmake | 65 ------------------------------------ sdk/cmake/config-arm.cmake | 47 -------------------------- sdk/cmake/config.cmake | 50 +++++++++++++++++++-------- sdk/cmake/gcc.cmake | 6 +--- 5 files changed, 38 insertions(+), 138 deletions(-) delete mode 100644 sdk/cmake/config-amd64.cmake delete mode 100644 sdk/cmake/config-arm.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 57fe94a8a5a..eca63cb4723 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,13 +49,7 @@ endif() include(sdk/include/reactos/version.cmake) # Compile options -if(ARCH STREQUAL "i386") - include(sdk/cmake/config.cmake) -elseif(ARCH STREQUAL "amd64") - include(sdk/cmake/config-amd64.cmake) -elseif(ARCH STREQUAL "arm") - include(sdk/cmake/config-arm.cmake) -endif() +include(sdk/cmake/config.cmake) # Compiler flags handling include(sdk/cmake/compilerflags.cmake) diff --git a/sdk/cmake/config-amd64.cmake b/sdk/cmake/config-amd64.cmake deleted file mode 100644 index 01ef763c719..00000000000 --- a/sdk/cmake/config-amd64.cmake +++ /dev/null @@ -1,65 +0,0 @@ - -set(SARCH "" CACHE STRING -"Sub-architecture to build for.") - -set(OARCH "athlon64" CACHE STRING -"Generate instructions for this CPU type. Specify one of: - k8 opteron athlon64 athlon-fx") - -set(OPTIMIZE "1" CACHE STRING -"What level of optimization to use. - 0 = off - 1 = Default option, optimize for size (-Os) with some additional options - 2 = Optimize for size (-Os) - 3 = Optimize debugging experience (-Og) - 4 = Optimize (-O1) - 5 = Optimize even more (-O2) - 6 = Optimize yet more (-O3) - 7 = Disregard strict standards compliance (-Ofast)") - -set(LTCG FALSE CACHE BOOL -"Whether to build with link-time code generation") - -set(DBG TRUE CACHE BOOL -"Whether to compile for debugging.") - -set(KDBG FALSE CACHE BOOL -"Whether to compile in the integrated kernel debugger.") - -set(GDB FALSE CACHE BOOL -"Whether to compile for debugging with GDB. -If you don't use GDB, don't enable this.") - -set(_WINKD_ TRUE CACHE BOOL -"Whether to compile with the KD protocol.") - -set(USERMODE TRUE CACHE BOOL -"Whether to compile any usermode parts. This is while kernel mode is under - heavy development and usermode part not relevant for bootcd.") - -if(MSVC) -set(_PREFAST_ FALSE CACHE BOOL -"Whether to enable PREFAST while compiling.") - # RTC are incompatible with compiler optimizations. - cmake_dependent_option(RUNTIME_CHECKS "Whether to enable runtime checks on MSVC" ON - "CMAKE_BUILD_TYPE STREQUAL Debug" OFF) -endif() - -if(CMAKE_C_COMPILER_ID STREQUAL "GNU") - set(GCC TRUE CACHE BOOL "The compiler is GCC") - set(CLANG FALSE CACHE BOOL "The compiler is LLVM Clang") -elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang") - # We can use LLVM Clang mimicking CL or GCC. Account for this - if (MSVC) - set(GCC FALSE CACHE BOOL "The compiler is GCC") - else() - set(GCC TRUE CACHE BOOL "The compiler is GCC") - endif() - set(CLANG TRUE CACHE BOOL "The compiler is LLVM Clang") -elseif(MSVC) # aka CMAKE_C_COMPILER_ID STEQUAL "MSVC" - set(GCC FALSE CACHE BOOL "The compiler is GCC") - set(CLANG FALSE CACHE BOOL "The compiler is LLVM Clang") - # MSVC variable is already set by cmake -else() - message("WARNING: the compiler has not been recognized") -endif() diff --git a/sdk/cmake/config-arm.cmake b/sdk/cmake/config-arm.cmake deleted file mode 100644 index 85992fed996..00000000000 --- a/sdk/cmake/config-arm.cmake +++ /dev/null @@ -1,47 +0,0 @@ - -set(SARCH "omap3-zoom2" CACHE STRING -"Sub-architecture (board) to build for. Specify one of: - kurobox versatile omap3-zoom2 omap3-beagle") - -set(OARCH "armv7-a" CACHE STRING -"Generate instructions for this CPU type. Specify one of: - armv5te armv7-a") - -set(OPTIMIZE "1" CACHE STRING -"What level of optimization to use. - 0 = off - 1 = Default option, optimize for size (-Os) with some additional options - 2 = Optimize for size (-Os) - 3 = Optimize debugging experience (-Og) - 4 = Optimize (-O1) - 5 = Optimize even more (-O2) - 6 = Optimize yet more (-O3) - 7 = Disregard strict standards compliance (-Ofast)") - -set(LTCG FALSE CACHE BOOL -"Whether to build with link-time code generation") - -set(DBG TRUE CACHE BOOL -"Whether to compile for debugging.") - -set(KDBG FALSE CACHE BOOL -"Whether to compile in the integrated kernel debugger.") - -set(GDB FALSE CACHE BOOL -"Whether to compile for debugging with GDB. -If you don't use GDB, don't enable this.") - -set(_WINKD_ TRUE CACHE BOOL -"Whether to compile with the KD protocol.") - -set(BUILD_MP TRUE CACHE BOOL -"Whether to compile the multi processor versions for ntoskrnl and hal.") - -set(NEWSPRINTF FALSE CACHE BOOL -"Whether to compile the new sprintf.") - -if(MSVC) - # RTC are incompatible with compiler optimizations. - cmake_dependent_option(RUNTIME_CHECKS "Whether to enable runtime checks on MSVC" ON - "CMAKE_BUILD_TYPE STREQUAL Debug" OFF) -endif() diff --git a/sdk/cmake/config.cmake b/sdk/cmake/config.cmake index fa6defa1eb5..eaf193ca8f1 100644 --- a/sdk/cmake/config.cmake +++ b/sdk/cmake/config.cmake @@ -1,14 +1,38 @@ -set(SARCH "pc" CACHE STRING -"Sub-architecture to build for. Specify one of: - pc pc98 xbox") +if(ARCH STREQUAL "i386") + set(SARCH "pc" CACHE STRING + "Sub-architecture to build for. Specify one of: + pc pc98 xbox") +elseif(ARCH STREQUAL "amd64") + set(SARCH "" CACHE STRING + "Sub-architecture to build for.") +elseif(ARCH STREQUAL "arm") + set(SARCH "omap3-zoom2" CACHE STRING + "Sub-architecture (board) to build for. Specify one of: + kurobox versatile omap3-zoom2 omap3-beagle") +endif() -set(OARCH "pentium" CACHE STRING -"Generate instructions for this CPU type. Specify one of: - pentium, pentiumpro") +if(ARCH STREQUAL "i386") + set(OARCH "pentium" CACHE STRING + "Generate instructions for this CPU type. Specify one of: + pentium, pentiumpro") +elseif(ARCH STREQUAL "amd64") + set(OARCH "athlon64" CACHE STRING + "Generate instructions for this CPU type. Specify one of: + k8 opteron athlon64 athlon-fx") +elseif(ARCH STREQUAL "arm") + set(OARCH "armv7-a" CACHE STRING + "Generate instructions for this CPU type. Specify one of: + armv5te armv7-a") +endif() -set(TUNE "i686" CACHE STRING -"Which CPU ReactOS should be optimized for.") +if(ARCH STREQUAL "i386" OR ARCH STREQUAL "amd64") + set(TUNE "generic" CACHE STRING + "Which CPU ReactOS should be optimized for.") +elseif(ARCH STREQUAL "arm") + set(TUNE "generic-arch" CACHE STRING + "Which CPU ReactOS should be optimized for.") +endif() set(OPTIMIZE "4" CACHE STRING "What level of optimization to use. @@ -73,17 +97,15 @@ else() set(_WINKD_ FALSE CACHE BOOL "Whether to compile with the KD protocol.") endif() -set(BUILD_MP TRUE CACHE BOOL -"Whether to build the multiprocessor versions of NTOSKRNL and HAL.") +cmake_dependent_option(BUILD_MP "Whether to build the multiprocessor versions of NTOSKRNL and HAL." ON + "ARCH STREQUAL i386" OFF) set(GENERATE_DEPENDENCY_GRAPH FALSE CACHE BOOL "Whether to create a GraphML dependency graph of DLLs.") if(MSVC) -set(_PREFAST_ FALSE CACHE BOOL -"Whether to enable PREFAST while compiling.") -set(_VS_ANALYZE_ FALSE CACHE BOOL -"Whether to enable static analysis while compiling.") + option(_PREFAST_ "Whether to enable PREFAST while compiling." OFF) + option(_VS_ANALYZE_ "Whether to enable static analysis while compiling." OFF) # RTC are incompatible with compiler optimizations. cmake_dependent_option(RUNTIME_CHECKS "Whether to enable runtime checks on MSVC" ON "CMAKE_BUILD_TYPE STREQUAL Debug" OFF) diff --git a/sdk/cmake/gcc.cmake b/sdk/cmake/gcc.cmake index b1d4b95fb14..4efeda21d07 100644 --- a/sdk/cmake/gcc.cmake +++ b/sdk/cmake/gcc.cmake @@ -90,11 +90,7 @@ if(NOT CMAKE_BUILD_TYPE STREQUAL "Release") endif() # Tuning -if(ARCH STREQUAL "i386") - add_compile_options(-march=${OARCH} -mtune=${TUNE}) -else() - add_compile_options(-march=${OARCH}) -endif() +add_compile_options(-march=${OARCH} -mtune=${TUNE}) # Warnings, errors if((NOT CMAKE_BUILD_TYPE STREQUAL "Release") AND (NOT CMAKE_C_COMPILER_ID STREQUAL Clang))