Skip to content

Commit 3e921d3

Browse files
committed
[CMake] Disallow direct configuration
As a first step, this allows us to generalize the detection of standalone builds and make it fully compatible when building in llvm/runtimes/ which automatically sets OPENMP_STANDLONE_BUILD. Differential Revision: https://reviews.llvm.org/D40080 llvm-svn: 319341
1 parent 8508201 commit 3e921d3

File tree

10 files changed

+28
-41
lines changed

10 files changed

+28
-41
lines changed

openmp/CMakeLists.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
22

3-
set(OPENMP_LLVM_TOOLS_DIR "" CACHE PATH "Path to LLVM tools for testing")
3+
# llvm/runtimes/ will set OPENMP_STANDALONE_BUILD.
4+
if (OPENMP_STANDALONE_BUILD OR "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
5+
set(OPENMP_STANDALONE_BUILD TRUE)
6+
project(openmp C CXX)
7+
8+
# CMAKE_BUILD_TYPE was not set, default to Release.
9+
if (NOT CMAKE_BUILD_TYPE)
10+
set(CMAKE_BUILD_TYPE Release)
11+
endif()
12+
13+
set(OPENMP_LLVM_TOOLS_DIR "" CACHE PATH "Path to LLVM tools for testing.")
14+
endif()
415

516
add_subdirectory(runtime)
617

openmp/libomptarget/Build_With_CMake.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ How to call cmake initially, then repeatedly
5151
=====================
5252
Instructions to Build
5353
=====================
54-
$ cd libomptarget_top_level/ [ directory with plugins/ , deviceRTLs/ , etc. ]
54+
$ cd openmp_top_level/ [ directory with runtime/, libomptarget/, etc. ]
5555
$ mkdir build
5656
$ cd build
5757

openmp/libomptarget/CMakeLists.txt

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,16 @@
1111
#
1212
##===----------------------------------------------------------------------===##
1313

14-
# CMAKE libomptarget
15-
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
14+
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
15+
message(FATAL_ERROR "Direct configuration not supported, please use parent directory!")
16+
endif()
1617

1718
# Add cmake directory to search for custom cmake functions.
1819
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules ${CMAKE_MODULE_PATH})
1920

20-
# Standalone build or part of LLVM?
21-
set(LIBOMPTARGET_STANDALONE_BUILD FALSE)
22-
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}" OR
23-
"${CMAKE_SOURCE_DIR}/libomptarget" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
24-
project(libomptarget C CXX)
25-
set(LIBOMPTARGET_STANDALONE_BUILD TRUE)
26-
endif()
27-
28-
29-
if(${LIBOMPTARGET_STANDALONE_BUILD})
21+
if(OPENMP_STANDALONE_BUILD)
3022
set(LIBOMPTARGET_ENABLE_WERROR FALSE CACHE BOOL
3123
"Enable -Werror flags to turn warnings into errors for supporting compilers.")
32-
# CMAKE_BUILD_TYPE was not defined, set default to Release
33-
if(NOT CMAKE_BUILD_TYPE)
34-
set(CMAKE_BUILD_TYPE Release)
35-
endif()
3624
set(LIBOMPTARGET_LIBDIR_SUFFIX "" CACHE STRING
3725
"suffix of lib installation directory, e.g. 64 => lib64")
3826

openmp/libomptarget/test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ else()
1616
set(LIBOMPTARGET_DEBUG False)
1717
endif()
1818

19-
if(${LIBOMPTARGET_STANDALONE_BUILD})
19+
if(${OPENMP_STANDALONE_BUILD})
2020
# Make sure we can use the console pool for recent cmake and ninja > 1.5
2121
if(CMAKE_VERSION VERSION_LESS 3.1.20141117)
2222
set(cmake_3_2_USES_TERMINAL)

openmp/runtime/Build_With_CMake.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ How to call cmake initially, then repeatedly
5151
=====================
5252
Instructions to Build
5353
=====================
54-
$ cd libomp_top_level/ [ directory with src/ , exports/ , tools/ , etc. ]
54+
$ cd openmp_top_level/ [ directory with runtime/, etc. ]
5555
$ mkdir build
5656
$ cd build
5757

openmp/runtime/CMakeLists.txt

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,13 @@
99
#//===----------------------------------------------------------------------===//
1010
#
1111

12-
# CMAKE libomp
13-
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
12+
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
13+
message(FATAL_ERROR "Direct configuration not supported, please use parent directory!")
14+
endif()
1415

1516
# Add cmake directory to search for custom cmake functions
1617
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
1718

18-
# Standalone build or part of LLVM?
19-
set(LIBOMP_STANDALONE_BUILD FALSE)
20-
if(OPENMP_STANDALONE_BUILD OR
21-
"${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}" OR
22-
"${CMAKE_SOURCE_DIR}/runtime" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
23-
project(libomp C CXX)
24-
set(LIBOMP_STANDALONE_BUILD TRUE)
25-
endif()
26-
2719
# Set libomp version
2820
set(LIBOMP_VERSION_MAJOR 5)
2921
set(LIBOMP_VERSION_MINOR 0)
@@ -35,7 +27,7 @@ include(LibompHandleFlags)
3527
include(LibompDefinitions)
3628

3729
# Determine the target architecture
38-
if(${LIBOMP_STANDALONE_BUILD})
30+
if(${OPENMP_STANDALONE_BUILD})
3931
# If adding a new architecture, take a look at cmake/LibompGetArchitecture.cmake
4032
libomp_get_architecture(LIBOMP_DETECTED_ARCH)
4133
set(LIBOMP_ARCH ${LIBOMP_DETECTED_ARCH} CACHE STRING
@@ -48,10 +40,6 @@ if(${LIBOMP_STANDALONE_BUILD})
4840
"enable assertions?")
4941
set(LIBOMP_ENABLE_WERROR FALSE CACHE BOOL
5042
"Enable -Werror flags to turn warnings into errors for supporting compilers.")
51-
# CMAKE_BUILD_TYPE was not defined, set default to Release
52-
if(NOT CMAKE_BUILD_TYPE)
53-
set(CMAKE_BUILD_TYPE Release)
54-
endif()
5543
else() # Part of LLVM build
5644
# Determine the native architecture from LLVM.
5745
string(TOLOWER "${LLVM_TARGET_ARCH}" LIBOMP_NATIVE_ARCH)
@@ -372,7 +360,7 @@ set(LIBOMP_INSTALL_ALIASES TRUE CACHE BOOL
372360
"Install libgomp and libiomp5 library aliases for backwards compatibility")
373361

374362
# Print configuration after all variables are set.
375-
if(${LIBOMP_STANDALONE_BUILD})
363+
if(${OPENMP_STANDALONE_BUILD})
376364
libomp_say("Operating System -- ${CMAKE_SYSTEM_NAME}")
377365
libomp_say("Target Architecture -- ${LIBOMP_ARCH}")
378366
if(${MIC})

openmp/runtime/src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ add_dependencies(libomp-micro-tests libomp-test-deps)
282282
# Install rules
283283
# We want to install libomp in DESTDIR/CMAKE_INSTALL_PREFIX/lib
284284
# We want to install headers in DESTDIR/CMAKE_INSTALL_PREFIX/include
285-
if(${LIBOMP_STANDALONE_BUILD})
285+
if(${OPENMP_STANDALONE_BUILD})
286286
set(LIBOMP_HEADERS_INSTALL_PATH include)
287287
else()
288288
string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION ${PACKAGE_VERSION})

openmp/runtime/test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pythonize_bool(LIBOMP_HAVE_LIBATOMIC)
4141
set(LIBOMP_TEST_CFLAGS "" CACHE STRING
4242
"Extra compiler flags to send to the test compiler")
4343

44-
if(${LIBOMP_STANDALONE_BUILD})
44+
if(${OPENMP_STANDALONE_BUILD})
4545
# Make sure we can use the console pool for recent cmake and ninja > 1.5
4646
if(CMAKE_VERSION VERSION_LESS 3.1.20141117)
4747
set(cmake_3_2_USES_TERMINAL)

openmp/www/README.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Out-of-tree build:
3636

3737
$ cd where-you-want-to-live
3838
Check out openmp
39-
$ cd where-you-want-to-live/openmp/runtime
39+
$ cd where-you-want-to-live/openmp
4040
$ mkdir build && cd build
4141
$ cmake path/to/openmp -DCMAKE_C_COMPILER=<C compiler> -DCMAKE_CXX_COMPILER=<C++ compiler>
4242
$ make

openmp/www/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ <h2>Get it and get involved!</h2>
183183
<ul>
184184
<li><code>cd where-you-want-to-live</code></li>
185185
<li>Check out openmp</li>
186-
<li><code>cd where-you-want-to-live/openmp/runtime</code></li>
186+
<li><code>cd where-you-want-to-live/openmp</code></li>
187187
<li><code>mkdir build &amp;&amp; cd build</code></li>
188188
<li><code>cmake path/to/openmp -DCMAKE_C_COMPILER=&lt;C compiler&gt; -DCMAKE_CXX_COMPILER=&lt;C++ compiler&gt;</code></li>
189189
<li><code>make</code></li>

0 commit comments

Comments
 (0)