Parcourir la source

Fix use of CMake build types

`Debug`, `Release`, and `RelWithDebInfo` set optimization levels and
also toggle debug generation.

Set `RelWithDebInfo` flags to be `-O3 -g` to match old `Test` mode
(normally it is `-O2 -g -DNDEBUG`).

Fixes #6419
Petr Penzin il y a 5 ans
Parent
commit
9d644c51c5
2 fichiers modifiés avec 11 ajouts et 10 suppressions
  1. 3 8
      CMakeLists.txt
  2. 8 2
      build.sh

+ 3 - 8
CMakeLists.txt

@@ -1,6 +1,8 @@
 cmake_minimum_required(VERSION 3.2)
 project (CHAKRACORE)
 
+set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g")
+
 # Keep CMake from caching static/shared library
 # option. Otherwise, CMake fails to update cached
 # references
@@ -402,19 +404,12 @@ if(CMAKE_BUILD_TYPE STREQUAL Debug)
         -D_DEBUG=1 # for PAL
         -DDBG_DUMP=1
     )
-elseif(CMAKE_BUILD_TYPE STREQUAL Test)
+elseif(CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo)
     add_definitions(
         -DENABLE_DEBUG_CONFIG_OPTIONS=1
     )
-    add_compile_options(-g)
 endif(CMAKE_BUILD_TYPE STREQUAL Debug)
 
-if(NOT CMAKE_BUILD_TYPE STREQUAL Debug)
-    add_compile_options(-O3)
-else()
-    add_compile_options(-O0)
-endif(NOT CMAKE_BUILD_TYPE STREQUAL Debug)
-
 if(IS_64BIT_BUILD)
     add_definitions(
         -DBIT64=1

+ 8 - 2
build.sh

@@ -203,7 +203,7 @@ while [[ $# -gt 0 ]]; do
         ;;
 
     -t | --test-build)
-        BUILD_TYPE="Test"
+        BUILD_TYPE="RelWithDebInfo"
         ;;
 
     -j | --jobs)
@@ -579,7 +579,13 @@ if [[ $HAS_LTTNG == 1 ]]; then
 fi
 
 
-BUILD_DIRECTORY="${TARGET_PATH}/${BUILD_TYPE:0}"
+if [[ ${BUILD_TYPE} =~ "RelWithDebInfo" ]]; then
+    BUILD_TYPE_DIR=Test
+else
+    BUILD_TYPE_DIR=${BUILD_TYPE}
+fi
+
+BUILD_DIRECTORY="${TARGET_PATH}/${BUILD_TYPE_DIR:0}"
 echo "Build path: ${BUILD_DIRECTORY}"
 
 BUILD_RELATIVE_DIRECTORY=$("$PYTHON2_BINARY" -c "import os.path;print \