Skip to content

Commit 66a0b75

Browse files
Tzvetan Mikovfacebook-github-bot
Tzvetan Mikov
authored andcommitted
CMake: require CMAKE_BUILD_TYPE (#1575)
Summary: Pull Request resolved: #1575 Instead of choosing defaults, require a build type to be explicitly specified. Reviewed By: avp Differential Revision: D66795928 fbshipit-source-id: 443d9a0971841deed73e63918c9294a61021c081
1 parent 4a42dbf commit 66a0b75

File tree

5 files changed

+11
-10
lines changed

5 files changed

+11
-10
lines changed

.circleci/config.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ jobs:
3838
# Tests can take a long time to run, since we don't need to attach a debugger
3939
# a Debug build with with -O2 lets us avoid timeouts and get results sooner.
4040
cmake -S hermes -B build -GNinja -DHERMES_ENABLE_INTL=ON \
41+
-DCMAKE_BUILD_TYPE=Debug \
4142
-DCMAKE_CXX_FLAGS=-O2 -DCMAKE_C_FLAGS=-O2 \
4243
-DHERMESVM_SANITIZE_HANDLES=<< parameters.sanitize >> \
4344
-DHERMES_ENABLE_UNDEFINED_BEHAVIOR_SANITIZER=<< parameters.sanitize >> \
@@ -67,6 +68,6 @@ jobs:
6768
- run:
6869
name: Run Hermes regression tests
6970
command: |
70-
cmake -S hermes -B build
71+
cmake -S hermes -B build -DCMAKE_BUILD_TYPE=Debug
7172
cmake --build build -j 2
7273
cmake --build build --target check-hermes -j 4

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@ jobs:
5151
path: hermes
5252
- name: Run Hermes regression tests
5353
run: |-
54-
cmake -S hermes -B build
54+
cmake -S hermes -B build -DCMAKE_BUILD_TYPE=Debug
5555
cmake --build build --target check-hermes all -j 4

CMakeLists.txt

+5-5
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ if (POLICY CMP0026)
4242
cmake_policy(SET CMP0026 OLD)
4343
endif()
4444

45+
# Require a build type
46+
if ((NOT GENERATOR_IS_MULTI_CONFIG) AND (NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL ""))
47+
message(FATAL_ERROR "Please set CMAKE_BUILD_TYPE")
48+
endif()
49+
4550
# Has to be set before `project` as per documentation
4651
# https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_SYSROOT.html
4752
set(CMAKE_OSX_SYSROOT ${HERMES_APPLE_TARGET_PLATFORM})
@@ -337,11 +342,6 @@ if (HERMESVM_INTERNAL_JAVASCRIPT_NATIVE)
337342
add_definitions(-DHERMESVM_INTERNAL_JAVASCRIPT_NATIVE)
338343
endif()
339344

340-
# Enable debug mode by default
341-
if ((NOT GENERATOR_IS_MULTI_CONFIG) AND CMAKE_BUILD_TYPE STREQUAL "")
342-
set(CMAKE_BUILD_TYPE Debug)
343-
endif()
344-
345345
if (HERMES_STATIC_LINK)
346346
append("-static" CMAKE_EXE_LINKER_FLAGS)
347347
set(HERMES_USE_STATIC_ICU ON)

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ To build a local debug version of the Hermes CLI tools the following steps shoul
2323
mkdir hermes_workingdir
2424
cd hermes_workingdir
2525
git clone https://github.com/facebook/hermes.git
26-
cmake -S hermes -B build -G Ninja
26+
cmake -S hermes -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug
2727
cmake --build ./build
2828
```
2929

doc/BuildingAndRunning.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Create a base directory to work in, e.g. `~/workspace`, and cd into it.
3333
After `cd`ing, follow the steps below to generate the Hermes build system:
3434

3535
git clone https://github.com/facebook/hermes.git
36-
cmake -S hermes -B build -G Ninja
36+
cmake -S hermes -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug
3737

3838
The build system has now been generated in the `build` directory. To perform the build:
3939

@@ -100,7 +100,7 @@ simply run:
100100
The `-HERMES_ENABLE_ADDRESS_SANITIZER=ON` flag will create a ASan build:
101101

102102
git clone https://github.com/facebook/hermes.git
103-
cmake -S hermes -B asan_build -G Ninja -D HERMES_ENABLE_ADDRESS_SANITIZER=ON
103+
cmake -S hermes -B asan_build -G Ninja -D HERMES_ENABLE_ADDRESS_SANITIZER=ON -DCMAKE_BUILD_TYPE=Debug
104104
cmake --build ./asan_build
105105

106106
You can verify the build by looking for `asan` symbols in the `hermes` binary:

0 commit comments

Comments
 (0)