2016-06-18 17:12:04 +03:00
cmake_minimum_required ( VERSION 3.4.3 )
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 )
2016-09-17 13:34:38 +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 )
endif ( WIN32 )
2016-04-08 17:36:37 +03:00
# Rely on llvm-config.
set ( CONFIG_OUTPUT )
find_program ( LLVM_CONFIG "llvm-config" )
if ( LLVM_CONFIG )
message ( STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}" )
set ( CONFIG_COMMAND ${ LLVM_CONFIG }
" - - a s s e r t i o n - m o d e "
" - - b i n d i r "
" - - l i b d i r "
" - - i n c l u d e d i r "
" - - p r e f i x "
" - - s r c - r o o t " )
execute_process (
C O M M A N D $ { C O N F I G _ C O M M A N D }
R E S U L T _ V A R I A B L E H A D _ E R R O R
O U T P U T _ V A R I A B L E C O N F I G _ O U T P U T
)
if ( NOT HAD_ERROR )
string ( REGEX REPLACE
" [ \ t ] * [ \ r \ n ] + [ \ t ] * " " ; "
C O N F I G _ O U T P U T $ { C O N F I G _ O U T P U T } )
2012-09-05 13:37:39 +04:00
else ( )
2016-04-08 17:36:37 +03:00
string ( REPLACE ";" " " CONFIG_COMMAND_STR "${CONFIG_COMMAND}" )
message ( STATUS "${CONFIG_COMMAND_STR}" )
message ( FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}" )
2012-09-05 13:37:39 +04:00
endif ( )
2016-04-08 17:36:37 +03:00
else ( )
message ( FATAL_ERROR "llvm-config not found -- ${LLVM_CONFIG}" )
2012-09-05 13:37:39 +04:00
endif ( )
2016-04-08 17:36:37 +03:00
list ( GET CONFIG_OUTPUT 0 ENABLE_ASSERTIONS )
list ( GET CONFIG_OUTPUT 1 TOOLS_BINARY_DIR )
list ( GET CONFIG_OUTPUT 2 LIBRARY_DIR )
list ( GET CONFIG_OUTPUT 3 INCLUDE_DIR )
list ( GET CONFIG_OUTPUT 4 LLVM_OBJ_ROOT )
list ( GET CONFIG_OUTPUT 5 MAIN_SRC_DIR )
if ( NOT MSVC_IDE )
set ( LLVM_ENABLE_ASSERTIONS ${ ENABLE_ASSERTIONS }
C A C H E B O O L " E n a b l e a s s e r t i o n s " )
# Assertions should follow llvm-config's.
mark_as_advanced ( LLVM_ENABLE_ASSERTIONS )
2012-09-05 13:37:39 +04:00
endif ( )
2016-04-08 17:36:37 +03:00
set ( LLVM_TOOLS_BINARY_DIR ${ TOOLS_BINARY_DIR } CACHE PATH "Path to llvm/bin" )
set ( LLVM_LIBRARY_DIR ${ LIBRARY_DIR } CACHE PATH "Path to llvm/lib" )
set ( LLVM_MAIN_INCLUDE_DIR ${ INCLUDE_DIR } CACHE PATH "Path to llvm/include" )
set ( LLVM_BINARY_DIR ${ LLVM_OBJ_ROOT } CACHE PATH "Path to LLVM build tree" )
set ( LLVM_MAIN_SRC_DIR ${ MAIN_SRC_DIR } CACHE PATH "Path to LLVM source tree" )
find_program ( LLVM_TABLEGEN_EXE "llvm-tblgen" ${ LLVM_TOOLS_BINARY_DIR }
N O _ D E F A U L T _ P A T H )
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 } )
else ( )
message ( FATAL_ERROR "Not found: ${LLVMCONFIG_FILE}" )
endif ( )
2012-09-05 13:37:39 +04:00
2014-03-10 00:45:27 +04:00
# They are used as destination of target generators.
set ( LLVM_RUNTIME_OUTPUT_INTDIR ${ CMAKE_BINARY_DIR } / ${ CMAKE_CFG_INTDIR } /bin )
2016-04-08 17:36:37 +03:00
set ( LLVM_LIBRARY_OUTPUT_INTDIR ${ CMAKE_BINARY_DIR } / ${ CMAKE_CFG_INTDIR } /lib ${ LLVM_LIBDIR_SUFFIX } )
if ( WIN32 OR CYGWIN )
# DLL platform -- put DLLs into bin.
set ( LLVM_SHLIB_OUTPUT_INTDIR ${ LLVM_RUNTIME_OUTPUT_INTDIR } )
else ( )
set ( LLVM_SHLIB_OUTPUT_INTDIR ${ LLVM_LIBRARY_OUTPUT_INTDIR } )
endif ( )
2014-03-10 00:45:27 +04:00
2016-04-08 17:36:37 +03:00
option ( LLVM_INSTALL_TOOLCHAIN_ONLY
" O n l y i n c l u d e t o o l c h a i n f i l e s i n t h e ' i n s t a l l ' t a r g e t . " O F F )
option ( LLVM_FORCE_USE_OLD_HOST_TOOLCHAIN
" S e t t o O N t o f o r c e u s i n g a n o l d , u n s u p p o r t e d h o s t t o o l c h a i n . " O F F )
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
2016-04-08 17:36:37 +03:00
include_directories ( "${LLVM_BINARY_DIR}/include" "${LLVM_MAIN_INCLUDE_DIR}" )
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 )
set ( Python_ADDITIONAL_VERSIONS 2.7 )
include ( FindPythonInterp )
if ( NOT PYTHONINTERP_FOUND )
message ( FATAL_ERROR
" U n a b l e t o f i n d P y t h o n i n t e r p r e t e r , r e q u i r e d f o r b u i l d s a n d t e s t i n g .
P l e a s e i n s t a l l P y t h o n o r s p e c i f y t h e P Y T H O N _ E X E C U T A B L E C M a k e v a r i a b l e . " )
endif ( )
if ( ${ PYTHON_VERSION_STRING } VERSION_LESS 2.7 )
message ( FATAL_ERROR "Python 2.7 or newer is required" )
endif ( )
# 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}" )
else ( )
set ( BACKEND_PACKAGE_STRING "${PACKAGE_STRING}" )
2012-09-05 13:37:39 +04:00
endif ( )
set ( CLING_SOURCE_DIR ${ CMAKE_CURRENT_SOURCE_DIR } )
set ( CLING_BINARY_DIR ${ CMAKE_CURRENT_BINARY_DIR } )
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 ( )
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 ( )
2015-10-30 19:02:22 +03:00
string ( REPLACE "-fvisibility=hidden" "" CMAKE_CXX_FLAGS ${ CMAKE_CXX_FLAGS } )
2014-02-21 00:56:13 +04:00
# The package needs to be compiler without RTTI information
if ( MSVC )
2016-02-23 11:24:23 +03:00
add_definitions ( /GR- /DNOMINMAX )
2014-02-21 00:56:13 +04:00
else ( )
add_definitions ( -fno-rtti )
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 } )
if ( DEFINED ROOT_BINARY_DIR )
# Building as part of ROOT.
set ( CLING_VERSION ROOT_ ${ CLING_VERSION } )
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 ( )
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 ( )
llvm_add_library ( ${ name } ${ ARG_ENABLE_SHARED } ${ ARG_UNPARSED_ARGUMENTS } ${ srcs } )
2014-03-08 16:15:48 +04:00
if ( TARGET ${ name } )
2016-06-18 17:12:04 +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 )
2016-10-14 11:28:22 +03:00
option ( ROOT_CLASSIC "Building as part of the ROOT (classic)." OFF )
2016-05-18 19:51:58 +03:00
if ( DEFINED ROOT_BINARY_DIR )
2016-07-13 18:15:31 +03:00
# Building as part of ROOT (CMake)
2016-05-18 19:51:58 +03:00
include_directories ( BEFORE
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / . . / l l v m / s r c / t o o l s / c l a n g / 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 } / . . / l l v m / s r c / t o o l s / c l a n g / i n c l u d e
)
2016-10-16 11:34:11 +03:00
elseif ( ROOT_CLASSIC )
2016-07-13 18:15:31 +03:00
# Building as part of ROOT (classic)
include_directories ( BEFORE
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / . . / l l v m / o b j / t o o l s / c l a n g / 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 } / . . / l l v m / s r c / t o o l s / c l a n g / i n c l u d e
)
2016-05-18 19:51:58 +03:00
else ( )
# and this when building Cling standalone:
include_directories ( BEFORE
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / . . / c l a n g / 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 } / . . / c l a n g / i n c l u d e
)
endif ( )
2014-10-02 14:34:09 +04:00
2016-04-08 17:36:37 +03:00
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 "
)
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 ( )
2016-08-12 22:54:47 +03:00
#Allow user to prepend to list via cmake -DCLING_INCLUDE_PATHS=
2016-09-06 16:31:49 +03:00
if ( DEFINED ROOT_BINARY_DIR )
2016-09-14 19:09:05 +03:00
if ( CLING_INCLUDE_TESTS )
2016-09-15 10:05:33 +03:00
set ( cling_include_deflt " ${ CMAKE_INSTALL_PREFIX } /include ${ cling_path_delim } \
2016-09-14 19:09:05 +03:00
$ { 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 i n g _ p a t h _ d e l i m } \
2016-09-06 16:31:49 +03:00
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / . . / l l v m / s r c / t o o l s / c l a n g / i n c l u d e $ { c l i n g _ p a t h _ d e l i m } \
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / . . / l l v m / s r c / i n c l u d e "
2016-09-14 19:09:05 +03:00
)
endif ( )
2016-09-06 16:31:49 +03:00
else ( )
2016-09-14 19:09:05 +03:00
if ( CLING_INCLUDE_TESTS )
2016-09-15 10:05:33 +03:00
set ( cling_include_deflt " ${ CMAKE_INSTALL_PREFIX } /include ${ cling_path_delim } \
2016-09-07 08:22:44 +03:00
$ { 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 i n g _ p a t h _ d e l i m } \
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / . . / c l a n g / i n c l u d e $ { c l i n g _ p a t h _ d e l i m } \
2016-08-12 22:54:47 +03:00
$ { 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 "
2016-09-14 19:09:05 +03:00
)
2016-09-15 12:19:19 +03:00
if ( WIN32 )
set ( cling_include_deflt " ${ cling_include_deflt } ${ cling_path_delim } \
2016-09-07 08:22:44 +03:00
$ { C M A K E _ B I N A R Y _ D I R } / i n c l u d e $ { c l i n g _ p a t h _ d e l i m } \
$ { C M A K E _ 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 "
2016-09-15 12:19:19 +03:00
)
endif ( )
2016-09-12 18:32:05 +03:00
endif ( )
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.
list ( APPEND LLVM_COMMON_DEPENDS intrinsics_gen )
2016-04-08 17:36:37 +03:00
add_subdirectory ( lib )
add_subdirectory ( tools )
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
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 . " )
if ( CLING_BUILT_STANDALONE OR CMAKE_VERSION VERSION_EQUAL 3 OR
C M A K E _ V E R S I O N V E R S I O N _ G R E A T E R 3 )
# Generate a list of CMake library targets so that other CMake projects can
# link against them. LLVM calls its version of this file LLVMExports.cmake, but
# the usual CMake convention seems to be ${Project}Targets.cmake.
set ( CLING_INSTALL_PACKAGE_DIR lib ${ LLVM_LIBDIR_SUFFIX } /cmake/cling )
set ( cling_cmake_builddir "${CMAKE_BINARY_DIR}/${CLING_INSTALL_PACKAGE_DIR}" )
get_property ( CLING_EXPORTS GLOBAL PROPERTY CLING_EXPORTS )
export ( TARGETS ${ CLING_EXPORTS } FILE ${ cling_cmake_builddir } /ClingTargets.cmake )
# Install a <prefix>/lib/cmake/cling/ClingConfig.cmake file so that
# find_package(Cling) works. Install the target list with it.
install ( EXPORT ClingTargets DESTINATION ${ CLING_INSTALL_PACKAGE_DIR } )
install ( FILES
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / c m a k e / m o d u l e s / C l i n g C o n f i g . c m a k 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 } / c m a k e / c l i n g )
2016-07-22 20:24:59 +03:00
install ( DIRECTORY tools/Jupyter/kernel DESTINATION share/cling/Jupyter )
2016-04-08 17:36:37 +03:00
# Also copy ClingConfig.cmake to the build directory so that dependent projects
# can build against a build directory of Cling more easily.
configure_file (
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / c m a k e / m o d u l e s / C l i n g C o n f i g . c m a k e
$ { C L I N G _ B I N A R Y _ D I R } / l i b $ { L L V M _ L I B D I R _ S U F F I X } / c m a k e / c l i n g / C l i n g C o n f i g . c m a k e
C O P Y O N L Y )
endif ( )