2023-08-17 15:24:09 +03:00
if ( WIN32 )
# We need cmake to support exporting of symbols not only from libraries but
# from executables too. This way cling can find symbols from its own
# executable during runtime.
cmake_minimum_required ( VERSION 3.6.2 )
else ( WIN32 )
# support of earlier cmake versions will be removed soon
cmake_minimum_required ( VERSION 3.5 )
endif ( WIN32 )
2014-01-07 14:57:25 +04:00
2012-09-05 13:37:39 +04:00
# If we are not building as a part of LLVM, build Cling as an
# standalone project, using LLVM as an external library:
if ( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
project ( Cling )
2024-05-18 23:32:38 +03:00
# See <https://llvm.org/docs/CMake.html#embedding-llvm-in-your-project>.
find_package ( LLVM REQUIRED CONFIG )
message ( STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}" )
message ( STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}" )
2016-04-08 17:36:37 +03:00
2024-05-18 23:32:38 +03:00
separate_arguments ( LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${ LLVM_DEFINITIONS } )
add_definitions ( ${ LLVM_DEFINITIONS_LIST } )
2012-09-05 13:37:39 +04:00
2024-05-18 23:32:38 +03:00
find_package ( Clang REQUIRED CONFIG )
message ( STATUS "Found supported version: Clang ${CLANG_PACKAGE_VERSION}" )
message ( STATUS "Using ClangConfig.cmake in: ${Clang_DIR}" )
2016-04-08 17:36:37 +03:00
find_program ( LLVM_TABLEGEN_EXE "llvm-tblgen" ${ LLVM_TOOLS_BINARY_DIR }
N O _ D E F A U L T _ P A T H )
2024-05-18 23:32:38 +03:00
list ( APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}" )
2012-09-05 13:37:39 +04:00
include ( AddLLVM )
2016-04-08 17:36:37 +03:00
include ( TableGen )
2012-09-05 13:37:39 +04:00
include ( HandleLLVMOptions )
2016-04-08 17:36:37 +03:00
include ( VersionFromVCS )
2012-09-05 13:37:39 +04:00
set ( PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}" )
2016-04-08 17:36:37 +03:00
if ( NOT DEFINED LLVM_INCLUDE_TESTS )
set ( LLVM_INCLUDE_TESTS ON )
endif ( )
2012-09-05 13:37:39 +04:00
2024-05-18 23:32:38 +03:00
include_directories ( "${LLVM_INCLUDE_DIRS}" )
2016-04-08 17:36:37 +03:00
link_directories ( "${LLVM_LIBRARY_DIR}" )
2012-09-05 13:37:39 +04:00
set ( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${ CMAKE_BINARY_DIR } /bin )
2016-04-08 17:36:37 +03:00
set ( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${ CMAKE_BINARY_DIR } /lib ${ LLVM_LIBDIR_SUFFIX } )
set ( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${ CMAKE_BINARY_DIR } /lib ${ LLVM_LIBDIR_SUFFIX } )
if ( LLVM_INCLUDE_TESTS )
2024-05-13 16:49:01 +03:00
find_package ( Python3 3.8 REQUIRED COMPONENTS Interpreter )
2016-04-08 17:36:37 +03:00
# Check prebuilt llvm/utils.
if ( EXISTS ${ LLVM_TOOLS_BINARY_DIR } /FileCheck ${ CMAKE_EXECUTABLE_SUFFIX }
A N D E X I S T S $ { L L V M _ T O O L S _ B I N A R Y _ D I R } / c o u n t $ { C M A K E _ E X E C U T A B L E _ S U F F I X }
A N D E X I S T S $ { L L V M _ T O O L S _ B I N A R Y _ D I R } / n o t $ { C M A K E _ E X E C U T A B L E _ S U F F I X } )
set ( LLVM_UTILS_PROVIDED ON )
endif ( )
if ( EXISTS ${ LLVM_MAIN_SRC_DIR } /utils/lit/lit.py )
set ( LLVM_LIT ${ LLVM_MAIN_SRC_DIR } /utils/lit/lit.py )
if ( NOT LLVM_UTILS_PROVIDED )
add_subdirectory ( ${ LLVM_MAIN_SRC_DIR } /utils/FileCheck utils/FileCheck )
add_subdirectory ( ${ LLVM_MAIN_SRC_DIR } /utils/count utils/count )
add_subdirectory ( ${ LLVM_MAIN_SRC_DIR } /utils/not utils/not )
set ( LLVM_UTILS_PROVIDED ON )
set ( CLING_TEST_DEPS FileCheck count not clang )
endif ( )
set ( UNITTEST_DIR ${ LLVM_MAIN_SRC_DIR } /utils/unittest )
if ( EXISTS ${ UNITTEST_DIR } /googletest/include/gtest/gtest.h
A N D N O T E X I S T S $ { L L V M _ L I B R A R Y _ D I R } / $ { C M A K E _ S T A T I C _ L I B R A R Y _ P R E F I X } g t e s t $ { C M A K E _ S T A T I C _ L I B R A R Y _ S U F F I X }
A N D E X I S T S $ { U N I T T E S T _ D I R } / C M a k e L i s t s . t x t )
add_subdirectory ( ${ UNITTEST_DIR } utils/unittest )
endif ( )
else ( )
# Seek installed Lit.
find_program ( LLVM_LIT "lit.py" ${ LLVM_MAIN_SRC_DIR } /utils/lit
D O C " P a t h t o l i t . p y " )
endif ( )
if ( LLVM_LIT )
# Define the default arguments to use with 'lit', and an option for the user
# to override.
set ( LIT_ARGS_DEFAULT "-sv" )
if ( MSVC OR XCODE )
set ( LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar" )
endif ( )
set ( LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit" )
# On Win32 hosts, provide an option to specify the path to the GnuWin32 tools.
if ( WIN32 AND NOT CYGWIN )
set ( LLVM_LIT_TOOLS_DIR "" CACHE PATH "Path to GnuWin32 tools" )
endif ( )
else ( )
set ( LLVM_INCLUDE_TESTS OFF )
endif ( )
endif ( )
2012-09-05 13:37:39 +04:00
set ( CLING_BUILT_STANDALONE 1 )
2016-04-08 17:36:37 +03:00
set ( BACKEND_PACKAGE_STRING "LLVM ${LLVM_PACKAGE_VERSION}" )
2023-08-08 23:17:43 +03:00
elseif ( DEFINED CLING_ROOT_BUILD )
message ( STATUS "Building Cling as part of ROOT" )
# we do not need to include LLVMConfig again, already done
else ( )
message ( STATUS "Building Cling as part of LLVM" )
2016-04-08 17:36:37 +03:00
set ( BACKEND_PACKAGE_STRING "${PACKAGE_STRING}" )
2021-02-26 22:43:13 +03:00
# Try finding the LLVMConfig.cmake if we build against prebuilt LLVM
2020-10-28 19:21:50 +03:00
set ( LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm" )
set ( LLVMCONFIG_FILE "${LLVM_CMAKE_PATH}/LLVMConfig.cmake" )
if ( EXISTS ${ LLVMCONFIG_FILE } )
list ( APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}" )
include ( ${ LLVMCONFIG_FILE } )
2021-02-26 22:43:13 +03:00
endif ( )
if ( NOT CLANG_INCLUDE_DIRS )
2023-01-13 18:36:29 +03:00
set ( CLANG_INCLUDE_DIRS "${LLVM_MAIN_SRC_DIR}/tools/clang/include" )
if ( NOT EXISTS ${ CLANG_INCLUDE_DIRS } )
# Otherwise assume the monorepo layout.
set ( CLANG_INCLUDE_DIRS ${ LLVM_MAIN_SRC_DIR } /../clang/include )
endif ( )
set ( CLANG_INCLUDE_DIRS "${CLANG_INCLUDE_DIRS}"
" $ { L L V M _ B I N A R Y _ D I R } / t o o l s / c l a n g / i n c l u d e " )
2020-10-28 19:21:50 +03:00
endif ( )
2023-12-05 16:28:02 +03:00
if ( NOT LLVM_INCLUDE_DIRS )
set ( LLVM_INCLUDE_DIRS "${LLVM_MAIN_SRC_DIR}/include" "${LLVM_BINARY_DIR}/include" )
endif ( )
2012-09-05 13:37:39 +04:00
endif ( )
2019-11-06 18:14:08 +03:00
if ( NOT "NVPTX" IN_LIST LLVM_TARGETS_TO_BUILD )
message ( FATAL_ERROR "NVPTX backend is not activated\n"
" P l e a s e e n a b l e i t v i a - D L L V M _ T A R G E T S _ T O _ B U I L D = \ " h o s t ; N V P T X \ " " )
endif ( )
2012-09-05 13:37:39 +04:00
set ( CLING_SOURCE_DIR ${ CMAKE_CURRENT_SOURCE_DIR } )
set ( CLING_BINARY_DIR ${ CMAKE_CURRENT_BINARY_DIR } )
2020-10-28 19:21:50 +03:00
set ( LLVM_TOOLS_BINARY_DIR "${LLVM_BINARY_DIR}/bin" )
2023-08-08 23:17:43 +03:00
if ( DEFINED CLING_ROOT_BUILD )
2020-10-28 19:21:50 +03:00
set ( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${LLVM_TOOLS_BINARY_DIR}" )
endif ( )
2012-09-05 13:37:39 +04:00
if ( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE )
message ( FATAL_ERROR "In-source builds are not allowed. CMake would overwrite "
" t h e m a k e f i l e s d i s t r i b u t e d w i t h L L V M . P l e a s e c r e a t e a d i r e c t o r y a n d r u n c m a k e "
" f r o m t h e r e , p a s s i n g t h e p a t h t o t h i s s o u r c e d i r e c t o r y a s t h e l a s t a r g u m e n t . "
" T h i s p r o c e s s c r e a t e d t h e f i l e ` C M a k e C a c h e . t x t ' a n d t h e d i r e c t o r y "
" ` C M a k e F i l e s ' . P l e a s e d e l e t e t h e m . " )
endif ( )
2016-09-29 12:16:22 +03:00
# From ROOT:
function ( cling_add_cxx_flag var flag )
string ( REGEX REPLACE "[-.+/:= ]" "_" flag_esc "${flag}" )
CHECK_CXX_COMPILER_FLAG ( "${flag}" CXX_HAS ${ flag_esc } )
if ( CXX_HAS ${ flag_esc } )
set ( ${ var } "${${var}} ${flag}" PARENT_SCOPE )
endif ( )
endfunction ( )
2019-09-03 18:28:54 +03:00
if ( CLING_ENABLE_WARNINGS AND NOT LLVM_ENABLE_WARNINGS AND ( LLVM_COMPILER_IS_GCC_COMPATIBLE OR CLANG_CL ) )
# from HandleLLCMOptions.cmake:
append ( "-Wall -W -Wno-unused-parameter -Wwrite-strings" CMAKE_C_FLAGS CMAKE_CXX_FLAGS )
append ( "-Wcast-qual" CMAKE_CXX_FLAGS )
# Turn off missing field initializer warnings for gcc to avoid noise from
# false positives with empty {}. Turn them on otherwise (they're off by
# default for clang).
check_cxx_compiler_flag ( "-Wmissing-field-initializers" CXX_SUPPORTS_MISSING_FIELD_INITIALIZERS_FLAG )
if ( CXX_SUPPORTS_MISSING_FIELD_INITIALIZERS_FLAG )
if ( CMAKE_COMPILER_IS_GNUCXX )
append ( "-Wno-missing-field-initializers" CMAKE_C_FLAGS CMAKE_CXX_FLAGS )
else ( )
append ( "-Wmissing-field-initializers" CMAKE_C_FLAGS CMAKE_CXX_FLAGS )
endif ( )
endif ( )
if ( LLVM_ENABLE_PEDANTIC AND LLVM_COMPILER_IS_GCC_COMPATIBLE )
append ( "-pedantic" CMAKE_C_FLAGS CMAKE_CXX_FLAGS )
append ( "-Wno-long-long" CMAKE_C_FLAGS CMAKE_CXX_FLAGS )
endif ( )
add_flag_if_supported ( "-Wcovered-switch-default" COVERED_SWITCH_DEFAULT_FLAG )
append_if ( USE_NO_UNINITIALIZED "-Wno-uninitialized" CMAKE_CXX_FLAGS )
append_if ( USE_NO_MAYBE_UNINITIALIZED "-Wno-maybe-uninitialized" CMAKE_CXX_FLAGS )
# Check if -Wnon-virtual-dtor warns even though the class is marked final.
# If it does, don't add it. So it won't be added on clang 3.4 and older.
# This also catches cases when -Wnon-virtual-dtor isn't supported by
# the compiler at all. This flag is not activated for gcc since it will
# incorrectly identify a protected non-virtual base when there is a friend
# declaration. Don't activate this in general on Windows as this warning has
# too many false positives on COM-style classes, which are destroyed with
# Release() (PR32286).
if ( NOT CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32 )
set ( OLD_CMAKE_REQUIRED_FLAGS ${ CMAKE_REQUIRED_FLAGS } )
2022-03-24 10:22:55 +03:00
set ( CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++14 -Werror=non-virtual-dtor" )
2019-09-03 18:28:54 +03:00
CHECK_CXX_SOURCE_COMPILES ( " class base {public: virtual void anchor( ) ; p r o t e c t e d : ~ base ( ) ; } ;
c l a s s d e r i v e d f i n a l : p u b l i c b a s e { p u b l i c : ~ derived ( ) ; } ;
i n t main ( ) { r e t u r n 0 ; } "
C X X _ W O N T _ W A R N _ O N _ F I N A L _ N O N V I R T U A L D T O R )
set ( CMAKE_REQUIRED_FLAGS ${ OLD_CMAKE_REQUIRED_FLAGS } )
append_if ( CXX_WONT_WARN_ON_FINAL_NONVIRTUALDTOR
" - W n o n - v i r t u a l - d t o r " C M A K E _ C X X _ F L A G S )
endif ( )
# Enable -Wdelete-non-virtual-dtor if available.
add_flag_if_supported ( "-Wdelete-non-virtual-dtor" DELETE_NON_VIRTUAL_DTOR_FLAG )
# Check if -Wcomment is OK with an // comment ending with '\' if the next
# line is also a // comment.
set ( OLD_CMAKE_REQUIRED_FLAGS ${ CMAKE_REQUIRED_FLAGS } )
set ( CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror -Wcomment" )
CHECK_C_SOURCE_COMPILES ( "// \\\\\\n//\\nint main() {return 0;}"
C _ W C O M M E N T _ A L L O W S _ L I N E _ W R A P )
set ( CMAKE_REQUIRED_FLAGS ${ OLD_CMAKE_REQUIRED_FLAGS } )
if ( NOT C_WCOMMENT_ALLOWS_LINE_WRAP )
append ( "-Wno-comment" CMAKE_C_FLAGS CMAKE_CXX_FLAGS )
endif ( )
# Enable -Wstring-conversion to catch misuse of string literals.
add_flag_if_supported ( "-Wstring-conversion" STRING_CONVERSION_FLAG )
endif ( )
2012-09-05 13:37:39 +04:00
# Add appropriate flags for GCC
if ( LLVM_COMPILER_IS_GCC_COMPATIBLE )
2016-04-08 17:36:37 +03:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common -Woverloaded-virtual" )
if ( NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing" )
endif ( )
2016-09-05 12:08:27 +03:00
foreach ( check_flag "-Wno-nested-anon-types" "-Wno-covered-switch-default" "-Wno-unused-local-typedef" )
2016-09-29 12:16:22 +03:00
cling_add_cxx_flag ( CMAKE_CXX_FLAGS ${ check_flag } )
2016-09-05 12:08:27 +03:00
endforeach ( )
2012-09-05 13:37:39 +04:00
endif ( )
2014-02-21 00:56:13 +04:00
# The package needs to be compiler without RTTI information
if ( MSVC )
2021-10-07 17:43:41 +03:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -GR-" )
2023-08-08 23:17:43 +03:00
if ( NOT DEFINED CLING_ROOT_BUILD )
2021-10-07 17:43:41 +03:00
# Add the /std:c++XX flag for Visual Studio if not building as part of ROOT
if ( MSVC_VERSION GREATER_EQUAL 1920 )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std:c++17" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING" )
elseif ( MSVC_VERSION GREATER_EQUAL 1910 )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std:c++14" )
endif ( )
2017-08-29 12:11:22 +03:00
endif ( )
2014-02-21 00:56:13 +04:00
else ( )
2017-02-20 04:06:42 +03:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti" )
endif ( )
if ( MSVC )
add_definitions ( /DNOMINMAX )
2014-02-21 00:56:13 +04:00
endif ( )
2014-02-19 21:52:42 +04:00
2012-09-05 13:37:39 +04:00
if ( APPLE )
set ( CMAKE_MODULE_LINKER_FLAGS "-Wl,-flat_namespace -Wl,-undefined -Wl,suppress" )
endif ( )
2016-04-08 17:36:37 +03:00
include ( CMakeParseArguments )
macro ( add_cling_subdirectory name )
add_llvm_subdirectory ( CLING TOOL ${ name } )
endmacro ( )
2012-09-05 13:37:39 +04:00
2016-05-18 19:51:58 +03:00
file ( STRINGS "VERSION" CLING_VERSION )
string ( REGEX REPLACE "([0-9]).[0-9]+~[a-zA-Z]+" "\\1" CLING_VERSION_MAJOR ${ CLING_VERSION } )
string ( REGEX REPLACE "[0-9].([0-9]+)~[a-zA-Z]+" "\\1" CLING_VERSION_MINOR ${ CLING_VERSION } )
2023-08-08 23:17:43 +03:00
if ( DEFINED CLING_ROOT_BUILD )
2021-05-19 13:06:46 +03:00
# Building as part of ROOT; visibility is "inherited" from ROOT/interpreter.
2016-05-18 19:51:58 +03:00
set ( CLING_VERSION ROOT_ ${ CLING_VERSION } )
2021-05-19 13:06:46 +03:00
else ( )
# Lots of cling is needed at runtime (e.g. Value, or Interpreter::Evaluate()).
# The JIT needs to be able to resolve these symbols from cling; unhide them.
2019-12-12 23:04:05 +03:00
set ( CMAKE_CXX_VISIBILITY_PRESET default )
set ( CMAKE_C_VISIBILITY_PRESET default )
set ( CMAKE_VISIBILITY_INLINES_HIDDEN "ON" )
2016-05-18 19:51:58 +03:00
endif ( )
message ( STATUS "Cling version (from VERSION file): ${CLING_VERSION}" )
set ( CLING_VERSION_PATCHLEVEL 0 )
macro ( set_cling_windows_version_resource_properties name )
if ( DEFINED windows_resource_file )
set_windows_version_resource_properties ( ${ name } ${ windows_resource_file }
V E R S I O N _ M A J O R $ { C L I N G _ V E R S I O N _ M A J O R }
V E R S I O N _ M I N O R $ { C L I N G _ V E R S I O N _ M I N O R }
V E R S I O N _ P A T C H L E V E L $ { C L I N G _ V E R S I O N _ P A T C H L E V E L }
V E R S I O N _ S T R I N G " $ { C L I N G _ V E R S I O N } ( $ { B A C K E N D _ P A C K A G E _ S T R I N G } ) "
P R O D U C T _ N A M E " c l i n g " )
endif ( )
endmacro ( )
2020-09-28 11:16:57 +03:00
include_directories ( BEFORE SYSTEM ${ LLVM_INCLUDE_DIRS } ${ CLANG_INCLUDE_DIRS } )
2020-09-10 10:09:53 +03:00
2012-09-05 13:37:39 +04:00
macro ( add_cling_library name )
2014-03-08 16:15:48 +04:00
cmake_parse_arguments ( ARG
2016-04-08 17:36:37 +03:00
" S H A R E D "
2014-03-08 16:15:48 +04:00
" "
" A D D I T I O N A L _ H E A D E R S "
$ { A R G N } )
set ( srcs )
2012-09-05 13:37:39 +04:00
if ( MSVC_IDE OR XCODE )
2014-03-08 16:15:48 +04:00
# Add public headers
file ( RELATIVE_PATH lib_path
$ { C L I N G _ S O U R C E _ D I R } / l i b /
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R }
)
if ( NOT lib_path MATCHES "^[.][.]" )
file ( GLOB_RECURSE headers
$ { C L I N G _ S O U R C E _ D I R } / i n c l u d e / c l i n g / $ { l i b _ p a t h } / * . h
$ { C L I N G _ S O U R C E _ D I R } / i n c l u d e / c l i n g / $ { l i b _ p a t h } / * . d e f
)
set_source_files_properties ( ${ headers } PROPERTIES HEADER_FILE_ONLY ON )
file ( GLOB_RECURSE tds
$ { C L I N G _ S O U R C E _ D I R } / i n c l u d e / c l i n g / $ { l i b _ p a t h } / * . t d
)
source_group ( "TableGen descriptions" FILES ${ tds } )
set_source_files_properties ( ${ tds } } PROPERTIES HEADER_FILE_ONLY ON )
if ( headers OR tds )
2016-04-08 17:36:37 +03:00
set ( srcs ${ headers } ${ tds } )
2014-03-08 16:15:48 +04:00
endif ( )
endif ( )
2012-09-05 13:37:39 +04:00
endif ( MSVC_IDE OR XCODE )
2014-03-08 16:15:48 +04:00
if ( srcs OR ARG_ADDITIONAL_HEADERS )
set ( srcs
A D D I T I O N A L _ H E A D E R S
$ { s r c s }
$ { A R G _ A D D I T I O N A L _ H E A D E R S } # It may contain unparsed unknown args.
)
endif ( )
2016-04-08 17:36:37 +03:00
if ( ARG_SHARED )
set ( ARG_ENABLE_SHARED SHARED )
endif ( )
2016-12-19 16:57:52 +03:00
if ( MSVC )
# On Windows exceptions aren’ t as generic as an x64 ABI.
# Stack unwinding code must be generated for every function between the
2016-12-20 14:18:35 +03:00
# throw and catch blocks.
2016-12-19 16:57:52 +03:00
if ( ${ name } STREQUAL "clingInterpreter" )
# All of libClingInterpreter is compiled with exceptions, mostly because
2016-12-20 14:18:35 +03:00
# llvm_unreachable throws an exception. Otherwise it could be reduced:
2016-12-19 16:57:52 +03:00
# Exception.cpp, Interpreter.cpp, IncrementalParser.cpp,
# IncrementalExecutor.cpp
set ( cling_ex_file_match ".cpp$" )
elseif ( ${ name } STREQUAL "clingUserInterface" )
# For libClingUserInterface, only UserInterface.cpp uses exceptions.
set ( cling_ex_file_match "^UserInterface.cpp$" )
endif ( )
if ( cling_ex_file_match )
# needs to be on before llvm_add_library so flags can be set below
set ( LLVM_REQUIRES_EH ON )
set ( LLVM_REQUIRES_RTTI ON )
endif ( )
endif ( )
2023-08-06 22:48:35 +03:00
# Set DISABLE_LLVM_LINK_LLVM_DYLIB to disable linking against shared LLVM
llvm_add_library ( ${ name } ${ ARG_ENABLE_SHARED } DISABLE_LLVM_LINK_LLVM_DYLIB ${ ARG_UNPARSED_ARGUMENTS } ${ srcs } )
2014-03-08 16:15:48 +04:00
2016-12-19 16:57:52 +03:00
if ( MSVC AND cling_ex_file_match )
# /EHs because cling_runtime_internal_throwIfInvalidPointer is extern “C”
if ( cling_ex_file_match )
foreach ( file_var ${ ARGN } )
if ( file_var MATCHES ${ cling_ex_file_match } )
set_property ( SOURCE ${ file_var } APPEND_STRING PROPERTY COMPILE_FLAGS
" / D _ H A S _ E X C E P T I O N S = 1 / E H s / G R / w d 4 7 1 4 " )
elseif ( file_var MATCHES ".cpp$" )
set_property ( SOURCE ${ file_var } APPEND_STRING PROPERTY COMPILE_FLAGS
" / D _ H A S _ E X C E P T I O N S = 0 / E H s - c - / G R - " )
endif ( )
endforeach ( )
endif ( )
endif ( )
2014-03-08 16:15:48 +04:00
if ( TARGET ${ name } )
2018-02-14 19:01:43 +03:00
target_link_libraries ( ${ name } INTERFACE ${ LLVM_COMMON_LIBS } )
2014-03-08 16:15:48 +04:00
if ( NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${ name } STREQUAL "libcling" )
install ( TARGETS ${ name }
2016-04-08 17:36:37 +03:00
C O M P O N E N T $ { n a m e }
E X P O R T C l i n g T a r g e t s
2014-03-08 16:15:48 +04:00
L I B R A R Y D E S T I N A T I O N l i b $ { L L V M _ L I B D I R _ S U F F I X }
A R C H I V E D E S T I N A T I O N l i b $ { L L V M _ L I B D I R _ S U F F I X }
R U N T I M E D E S T I N A T I O N b i n )
2016-04-08 17:36:37 +03:00
if ( ${ ARG_SHARED } AND NOT CMAKE_CONFIGURATION_TYPES )
add_custom_target ( install- ${ name }
D E P E N D S $ { n a m e }
C O M M A N D " $ { C M A K E _ C O M M A N D } "
- D C M A K E _ I N S T A L L _ C O M P O N E N T = $ { n a m e }
- P " $ { C M A K E _ B I N A R Y _ D I R } / c m a k e _ i n s t a l l . c m a k e " )
endif ( )
2014-03-08 16:15:48 +04:00
endif ( )
2016-04-08 17:36:37 +03:00
set_property ( GLOBAL APPEND PROPERTY CLING_EXPORTS ${ name } )
2012-09-05 13:37:39 +04:00
else ( )
2014-03-08 16:15:48 +04:00
# Add empty "phony" target
add_custom_target ( ${ name } )
2012-09-05 13:37:39 +04:00
endif ( )
2014-03-08 16:15:48 +04:00
2012-09-05 13:37:39 +04:00
set_target_properties ( ${ name } PROPERTIES FOLDER "Cling libraries" )
2016-04-08 17:36:37 +03:00
set_cling_windows_version_resource_properties ( ${ name } )
2012-09-05 13:37:39 +04:00
endmacro ( add_cling_library )
macro ( add_cling_executable name )
add_llvm_executable ( ${ name } ${ ARGN } )
set_target_properties ( ${ name } PROPERTIES FOLDER "Cling executables" )
2016-04-08 17:36:37 +03:00
set_cling_windows_version_resource_properties ( ${ name } )
2012-09-05 13:37:39 +04:00
endmacro ( add_cling_executable )
2016-04-08 17:36:37 +03:00
set ( CMAKE_INCLUDE_CURRENT_DIR ON )
include_directories ( BEFORE
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / i n c l u d e
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / i n c l u d e
2012-09-05 13:37:39 +04:00
)
2016-04-08 17:36:37 +03:00
if ( NOT LLVM_INSTALL_TOOLCHAIN_ONLY )
install ( DIRECTORY include/cling include/cling-c
D E S T I N A T I O N i n c l u d e
F I L E S _ M A T C H I N G
P A T T E R N " * . d e f "
P A T T E R N " * . h "
P A T T E R N " c o n f i g . h " E X C L U D E
P A T T E R N " . s v n " E X C L U D E
)
2012-09-05 13:37:39 +04:00
2016-04-08 17:36:37 +03:00
install ( DIRECTORY ${ CMAKE_CURRENT_BINARY_DIR } /include/cling
D E S T I N A T I O N i n c l u d e
F I L E S _ M A T C H I N G
P A T T E R N " C M a k e F i l e s " E X C L U D E
P A T T E R N " * . i n c "
P A T T E R N " * . h "
2021-03-10 23:22:28 +03:00
P A T T E R N " * . m o d u l e m a p "
2016-04-08 17:36:37 +03:00
)
endif ( )
2014-05-09 16:46:58 +04:00
2016-08-12 22:54:47 +03:00
add_definitions ( -D_GNU_SOURCE -DCLING_VERSION= ${ CLING_VERSION } )
2015-12-22 21:57:04 +03:00
2014-01-28 17:30:55 +04:00
option ( CLING_INCLUDE_TESTS
" G e n e r a t e b u i l d t a r g e t s f o r t h e C l i n g u n i t t e s t s . "
$ { L L V M _ I N C L U D E _ T E S T S } )
2016-09-07 08:22:44 +03:00
if ( NOT WIN32 )
set ( cling_path_delim ":" )
else ( )
set ( cling_path_delim ";" )
endif ( )
2018-02-14 17:57:10 +03:00
if ( CLING_INCLUDE_TESTS )
2018-03-03 17:34:10 +03:00
set ( cling_include_deflt ${ CMAKE_INSTALL_PREFIX } /include
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / i n c l u d e
$ { C L A N G _ I N C L U D E _ D I R S }
$ { L L V M _ I N C L U D E _ D I R S }
)
# CLANG_INCLUDE_DIRS and LLVM_INCLUDE_DIRS can be a semicolon separated lists.
2018-03-22 15:34:29 +03:00
string ( REPLACE ";" "${cling_path_delim}" cling_include_deflt "${cling_include_deflt}" )
2016-09-07 08:22:44 +03:00
endif ( )
2016-08-12 22:54:47 +03:00
if ( NOT CLING_INCLUDE_PATHS )
set ( CLING_INCLUDE_PATHS "${cling_include_deflt}" )
else ( )
2016-09-07 08:22:44 +03:00
set ( CLING_INCLUDE_PATHS "${CLING_INCLUDE_PATHS}${cling_path_delim}${cling_include_deflt}" )
2016-08-12 22:54:47 +03:00
endif ( )
2016-07-19 18:38:49 +03:00
# All targets below may depend on all tablegen'd files.
get_property ( CLANG_TABLEGEN_TARGETS GLOBAL PROPERTY CLANG_TABLEGEN_TARGETS )
list ( APPEND LLVM_COMMON_DEPENDS ${ CLANG_TABLEGEN_TARGETS } )
# And llvm-intrinsics.
2018-02-14 19:02:57 +03:00
if ( TARGET intrinsics_gen )
list ( APPEND LLVM_COMMON_DEPENDS intrinsics_gen )
endif ( )
2018-03-28 18:17:55 +03:00
if ( TARGET clang-headers )
list ( APPEND LLVM_COMMON_DEPENDS clang-headers )
endif ( )
2016-07-19 18:38:49 +03:00
2024-02-06 16:52:32 +03:00
add_subdirectory ( include/cling/Interpreter )
2016-04-08 17:36:37 +03:00
add_subdirectory ( lib )
2014-01-28 17:30:55 +04:00
if ( CLING_INCLUDE_TESTS )
add_subdirectory ( test )
2012-09-05 13:37:39 +04:00
2016-04-08 17:36:37 +03:00
if ( CLING_BUILT_STANDALONE )
# Add a global check rule now that all subdirectories have been traversed
# and we know the total set of lit testsuites.
get_property ( LLVM_LIT_TESTSUITES GLOBAL PROPERTY LLVM_LIT_TESTSUITES )
get_property ( LLVM_LIT_PARAMS GLOBAL PROPERTY LLVM_LIT_PARAMS )
get_property ( LLVM_LIT_DEPENDS GLOBAL PROPERTY LLVM_LIT_DEPENDS )
get_property ( LLVM_LIT_EXTRA_ARGS GLOBAL PROPERTY LLVM_LIT_EXTRA_ARGS )
add_lit_target ( check-all
" R u n n i n g a l l r e g r e s s i o n t e s t s "
$ { L L V M _ L I T _ T E S T S U I T E S }
P A R A M S $ { L L V M _ L I T _ P A R A M S }
D E P E N D S $ { L L V M _ L I T _ D E P E N D S }
A R G S $ { L L V M _ L I T _ E X T R A _ A R G S }
)
2012-09-05 13:37:39 +04:00
endif ( )
endif ( )
2016-04-08 17:36:37 +03:00
2019-03-17 00:27:52 +03:00
add_subdirectory ( tools )
2016-04-08 17:36:37 +03:00
option ( CLING_INCLUDE_DOCS "Generate build targets for the Cling docs."
$ { L L V M _ I N C L U D E _ D O C S } )
if ( CLING_INCLUDE_DOCS )
add_subdirectory ( docs )
endif ( )
if ( EXISTS "${CMAKE_CURRENT_BINARY_DIR}/cling.order" )
file ( REMOVE "${CMAKE_CURRENT_BINARY_DIR}/cling.order" )
endif ( )
if ( CLING_ORDER_FILE STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/cling.order" )
unset ( CLING_ORDER_FILE CACHE )
unset ( CLING_ORDER_FILE )
endif ( )
set ( CLING_ORDER_FILE "" CACHE FILEPATH
" O r d e r f i l e t o u s e w h e n c o m p i l i n g c l i n g i n o r d e r t o i m p r o v e s t a r t u p t i m e . " )
2020-09-18 12:05:01 +03:00
add_subdirectory ( cmake/modules )