@@ -6,6 +6,16 @@ set(CMAKE_MODULE_PATH
66 "${CMAKE_CURRENT_SOURCE_DIR} /cmake/modules"
77 )
88
9+ enable_language (CXX)
10+ set (CMAKE_CXX_EXTENSIONS NO )
11+
12+ option (CPPINTEROP_USE_CLING "Use Cling as backend" OFF )
13+ option (CPPINTEROP_USE_REPL "Use clang-repl as backend" ON )
14+ option (CPPINTEROP_ENABLE_TESTING "Enable the CppInterOp testing infrastructure." ON )
15+
16+ if (CPPINTEROP_USE_CLING AND CPPINTEROP_USE_REPL)
17+ message (FATAL_ERROR "We can only use Cling (${CPPINTEROP_USE_CLING} =On) or Repl (CPPINTEROP_USE_REPL=On), but not both of them." )
18+ endif ()
919# If we are not building as a part of LLVM, build CppInterOp as a standalone
1020# project, using LLVM as an external library:
1121if ( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
@@ -51,19 +61,10 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
5161 endif ()
5262 if (NOT DEFINED Clang_DIR)
5363 set (Clang_DIR ${Cling_DIR} )
54- endif ()
5564 endif ()
65+ endif ()
5666
57- enable_language (CXX)
58- set (CMAKE_CXX_EXTENSIONS NO )
5967include (GNUInstallDirs)
60- option (CPPINTEROP_USE_CLING "Use Cling as backend" OFF )
61- option (CPPINTEROP_USE_REPL "Use clang-repl as backend" ON )
62-
63- if (CPPINTEROP_USE_CLING AND CPPINTEROP_USE_REPL)
64- message (FATAL_ERROR "We can only use Cling (CPPINTEROP_USE_CLING=On) or Repl (CPPINTEROP_USE_REPL=On), but not both of them." )
65- endif ()
66-
6768 ## Define supported version of clang and llvm
6869
6970 set (CLANG_MIN_SUPPORTED 13.0)
@@ -292,16 +293,15 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
292293# In rare cases we might want to have clang installed in a different place
293294# than llvm and the header files should be found first (even though the
294295# LLVM_INCLUDE_DIRS) contain clang headers, too.
295- if (CPPINTEROP_USE_CLING)
296+ if (CPPINTEROP_USE_CLING)
296297 add_definitions (-DCPPINTEROP_USE_CLING)
297298 include_directories (SYSTEM ${CLING_INCLUDE_DIRS} )
298- else ()
299- if (NOT CPPINTEROP_USE_REPL)
300- message (FATAL_ERROR "We need either CPPINTEROP_USE_CLING or CPPINTEROP_USE_REPL" )
301- endif ()
299+ elseif (CPPINTEROP_USE_REPL)
302300 add_definitions (-DCPPINTEROP_USE_REPL)
301+ else ()
302+ message (FATAL_ERROR "We need either CPPINTEROP_USE_CLING or CPPINTEROP_USE_REPL" )
303+ endif ()
303304
304- endif (CPPINTEROP_USE_CLING)
305305include_directories (SYSTEM ${CLANG_INCLUDE_DIRS} )
306306include_directories (SYSTEM ${LLVM_INCLUDE_DIRS} )
307307separate_arguments (LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS} )
@@ -453,10 +453,7 @@ option(CPPINTEROP_ENABLE_SPHINX "Use sphinx to generage CppInterOp user document
453453
454454if (EMSCRIPTEN)
455455 message ("Build with emscripten" )
456- option (CPPINTEROP_ENABLE_TESTING "Enables the testing infrastructure." OFF )
457- else ()
458- message ("Build with cmake" )
459- option (CPPINTEROP_ENABLE_TESTING "Enables the testing infrastructure." ON )
456+ set (CPPINTEROP_ENABLE_TESTING OFF )
460457endif ()
461458
462459if (MSVC )
0 commit comments