2014-01-07 14:57:25 +04:00
#------------------------------------------------------------------------------
# CLING - the C++ LLVM-based InterpreterG :)
#
# This file is dual-licensed: you can choose to license it under the University
# of Illinois Open Source License or the GNU Lesser General Public License. See
# LICENSE.TXT for details.
#------------------------------------------------------------------------------
2016-07-19 18:42:47 +03:00
set ( LIBS
c l a n g D r i v e r
c l a n g F r o n t e n d
c l a n g P a r s e
c l a n g S e m a
c l a n g A S T
c l a n g L e x
c l a n g S e r i a l i z a t i o n
c l a n g C o d e G e n
c l a n g B a s i c
c l i n g U t i l s
)
2012-09-05 13:37:39 +04:00
set ( LLVM_LINK_COMPONENTS
2016-07-19 18:42:47 +03:00
a n a l y s i s
c o r e
e x e c u t i o n e n g i n e
i p o
m c
2014-03-28 19:45:34 +04:00
n a t i v e
2016-07-19 18:42:47 +03:00
n a t i v e c o d e g e n
o b j e c t
2014-03-28 19:45:34 +04:00
o p t i o n
2016-07-19 18:42:47 +03:00
o r c j i t
r u n t i m e d y l d
2016-11-15 17:22:06 +03:00
s c a l a r o p t s
2016-07-19 18:42:47 +03:00
s u p p o r t
t a r g e t
2016-11-15 17:22:06 +03:00
t r a n s f o r m u t i l s
2012-09-05 13:37:39 +04:00
)
2016-07-18 17:58:49 +03:00
add_cling_library ( clingInterpreter OBJECT
2013-03-01 20:22:32 +04:00
A u t o S y n t h e s i z e r . c p p
2014-06-08 01:52:32 +04:00
A u t o l o a d C a l l b a c k . c p p
2016-04-11 13:12:21 +03:00
A S T T r a n s f o r m e r . c p p
2015-02-12 12:08:01 +03:00
B a c k e n d P a s s e s . c p p
2013-10-30 18:59:05 +04:00
C h e c k E m p t y T r a n s a c t i o n T r a n s f o r m e r . c p p
2012-09-05 13:37:39 +04:00
C I F a c t o r y . c p p
2013-09-20 14:01:10 +04:00
C l a n g I n t e r n a l S t a t e . c p p
2016-06-23 19:09:06 +03:00
C l i n g C o d e C o m p l e t e C o n s u m e r . c p p
2015-02-18 12:44:12 +03:00
C l i n g P r a g m a s . c p p
2012-09-05 13:37:39 +04:00
D e c l C o l l e c t o r . c p p
D e c l E x t r a c t o r . c p p
2016-06-26 11:06:18 +03:00
D e c l U n l o a d e r . c p p
2013-09-24 18:24:53 +04:00
D y n a m i c L i b r a r y M a n a g e r . c p p
2012-09-05 13:37:39 +04:00
D y n a m i c L o o k u p . c p p
D y n a m i c E x p r I n f o . c p p
2016-04-11 13:12:21 +03:00
E x c e p t i o n . c p p
2016-07-07 11:47:58 +03:00
E x t e r n a l I n t e r p r e t e r S o u r c e . c p p
2014-06-23 15:46:34 +04:00
F o r w a r d D e c l P r i n t e r . c p p
2014-02-19 15:49:24 +04:00
I n c r e m e n t a l E x e c u t o r . c p p
2015-02-10 19:03:11 +03:00
I n c r e m e n t a l J I T . c p p
2012-09-05 13:37:39 +04:00
I n c r e m e n t a l P a r s e r . c p p
I n t e r p r e t e r . c p p
2012-10-09 14:29:44 +04:00
I n t e r p r e t e r C a l l b a c k s . c p p
2012-09-05 13:37:39 +04:00
I n v o c a t i o n O p t i o n s . c p p
L o o k u p H e l p e r . c p p
2013-09-17 18:49:58 +04:00
N u l l D e r e f P r o t e c t i o n T r a n s f o r m e r . c p p
2012-11-02 12:11:24 +04:00
R e q u i r e d S y m b o l s . c p p
2012-09-05 13:37:39 +04:00
T r a n s a c t i o n . c p p
2014-03-31 18:48:38 +04:00
T r a n s a c t i o n U n l o a d e r . c p p
2016-04-11 13:12:21 +03:00
V a l u e E x t r a c t i o n S y n t h e s i z e r . c p p
2013-02-25 11:47:39 +04:00
V a l u e . c p p
2012-09-05 13:37:39 +04:00
V a l u e P r i n t e r . c p p
2015-12-16 17:54:45 +03:00
V a l u e P r i n t e r S y n t h e s i z e r . c p p
2016-10-12 13:42:06 +03:00
D E P E N D S
C l a n g D r i v e r O p t i o n s
2015-12-16 17:54:45 +03:00
L I N K _ L I B S
2016-07-19 18:42:47 +03:00
$ { L I B S }
)
2014-08-04 06:05:42 +04:00
2012-09-05 13:37:39 +04:00
#add_dependencies(clangDriver ClangAttrList ClangDiagnosticDriver
# ClangDriverOptions ClangCC1Options ClangCC1AsOptions)
2014-01-14 19:14:18 +04:00
2016-08-11 13:12:20 +03:00
if ( UNIX )
2016-12-19 16:57:52 +03:00
set_source_files_properties ( Exception.cpp COMPILE_FLAGS "-fexceptions -frtti" )
2014-04-09 20:12:57 +04:00
2016-08-11 13:12:20 +03:00
# Remove all -I from CMAKE_CXX_FLAGS
string ( REPLACE ";" " " __flags "${CMAKE_CXX_FLAGS}" )
string ( REGEX REPLACE "-I[^ ]+" "" CLING_COMPILER_FLAGS_NO_I "${__flags}" )
option ( CLING_CXX_PATH "Compiler cling will invoke for c++ headers." "" )
option ( CLING_CXX_HEADERS "Path cling will use for c++ headers." "" )
function ( stripNewLine strVal varName )
string ( STRIP "${strVal}" strVal )
string ( REGEX REPLACE "\\n$" "" strVal "${strVal}" )
SET ( ${ varName } ${ strVal } PARENT_SCOPE )
endfunction ( )
if ( NOT CLING_CXX_PATH )
# Remove absolute path from CMAKE_CXX_COMPILER
2016-10-18 16:15:27 +03:00
get_filename_component ( _name ${ CMAKE_CXX_COMPILER } NAME )
get_filename_component ( _path ${ CMAKE_CXX_COMPILER } PATH )
2016-08-11 13:12:20 +03:00
# This should probably be more general...but how?
if ( _name STREQUAL "ccache" OR _name STREQUAL "distcc" )
separate_arguments ( _arg_list UNIX_COMMAND "${CMAKE_CXX_COMPILER_ARG1}" )
if ( _arg_list )
list ( GET _arg_list 0 _name )
string ( STRIP "${_name}" _name )
if ( APPLE )
execute_process ( COMMAND xcrun -f ${ _name }
O U T P U T _ V A R I A B L E C L I N G _ C X X _ F O U N D
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
stripNewLine ( "${CLING_CXX_FOUND}" CLING_CXX_FOUND )
else ( )
find_program ( _cling_cxx_path "${_name}" )
execute_process ( COMMAND ${ _cling_cxx_path } -xc++ -E -v /dev/null
O U T P U T _ Q U I E T E R R O R _ V A R I A B L E _ c l i n g _ c x x _ p a t h )
if ( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
execute_process (
C O M M A N D e c h o $ { _ c l i n g _ c x x _ p a t h }
C O M M A N D g r e p " C O L L E C T _ G C C = "
O U T P U T _ V A R I A B L E _ c l i n g _ c x x _ p a t h )
string ( REPLACE "COLLECT_GCC=" "" _cling_cxx_path "${_cling_cxx_path}" )
elseif ( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
execute_process (
C O M M A N D e c h o $ { _ c l i n g _ c x x _ p a t h }
C O M M A N D g r e p " / $ { _ n a m e } \ " - c c 1 "
O U T P U T _ V A R I A B L E _ c l i n g _ c l n g _ p a t h )
if ( NOT _cling_clng_path )
execute_process (
C O M M A N D e c h o $ { _ c l i n g _ c x x _ p a t h }
C O M M A N D g r e p " / c l a n g \ " - c c 1 "
O U T P U T _ V A R I A B L E _ c l i n g _ c l n g _ p a t h )
endif ( )
separate_arguments ( _arg_list UNIX_COMMAND "${_cling_clng_path}" )
if ( _arg_list )
list ( GET _arg_list 0 _cling_cxx_path )
endif ( )
endif ( )
stripNewLine ( "${_cling_cxx_path}" _cling_cxx_path )
set ( CLING_CXX_FOUND "${_cling_cxx_path}" )
endif ( )
if ( NOT EXISTS "${CLING_CXX_FOUND}" )
find_program ( CLING_CXX_FOUND "${_name}" )
endif ( )
else ( )
set ( CLING_CXX_FOUND "" )
set ( _name "" )
endif ( )
if ( EXISTS ${ CLING_CXX_FOUND } )
set ( CLING_CXX_PATH ${ CLING_CXX_FOUND } )
get_filename_component ( _name ${ CLING_CXX_PATH } NAME )
get_filename_component ( _path ${ CLING_CXX_PATH } PATH )
else ( )
set ( CLING_CXX_PATH "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}" )
if ( _name )
set ( CLING_CXX_RLTV "${_name}" )
endif ( )
set ( _path "__THISREALLYBETTERNOTBEINPATH_THANKS__" )
endif ( )
else ( )
2016-10-18 16:15:27 +03:00
# FIXME: In some ccache setups we can have a soft link pointing to ccache
# binary. Eg. /usr/local/gcc -> /usr/bin/ccache. Resolving the realpath
# we will get to the ccache and not the intended compiler binary. This
# could be fixed if we run 'gcc -###' which will give us the correct info.
2016-11-01 20:16:11 +03:00
get_filename_component ( _realpath ${ CMAKE_CXX_COMPILER } REALPATH )
get_filename_component ( _name ${ _realpath } NAME )
get_filename_component ( _path ${ _realpath } PATH )
2016-08-11 13:12:20 +03:00
endif ( )
2016-10-18 11:18:29 +03:00
# Test if path compiler is on PATH.
string ( REPLACE ":" ";" _pathlist $ENV{ PATH } )
foreach ( _pathcomp ${ _pathlist } )
get_filename_component ( _pathcomp ${ _pathcomp } REALPATH )
2016-11-01 20:15:02 +03:00
if ( _path STREQUAL _pathcomp )
2016-10-18 11:18:29 +03:00
# This adds a lot of unneccessary flags, but may be useful if there's
# a flag that should be passed to cling.
set ( CLING_CXX_RLTV ${ _name } )
break ( )
endif ( )
endforeach ( )
# FIXME: Perhaps CLING_CXX_RLTV should have a better name?
if ( NOT CLING_CXX_RLTV AND NOT CLING_CXX_PATH )
# We got nothing, just use whatever CMake is using.
2016-08-11 13:12:20 +03:00
set ( CLING_CXX_PATH ${ CMAKE_CXX_COMPILER } )
endif ( )
2016-08-23 02:45:23 +03:00
# If CMAKE_CXX_FLAGS contains --gcc-toolchain= then that should be passed on
string ( FIND "${CMAKE_CXX_FLAGS}" "--gcc-toolchain=" cling_gcc_toolchain )
if ( "${cling_gcc_toolchain}" GREATER -1 )
2016-10-18 11:18:29 +03:00
# TODO Refactor these two into common function
2016-08-23 02:45:23 +03:00
if ( CLING_CXX_PATH )
string ( FIND "${CLING_CXX_PATH}" "--gcc-toolchain=" cling_gcc_toolchain )
if ( "${cling_gcc_toolchain}" EQUAL -1 )
set ( CLING_CXX_PATH "${CLING_CXX_PATH} --gcc-toolchain=${gcctoolchain}" )
endif ( )
endif ( )
if ( CLING_CXX_RLTV )
string ( FIND "${CLING_CXX_RLTV}" "--gcc-toolchain=" cling_gcc_toolchain )
if ( "${cling_gcc_toolchain}" EQUAL -1 )
set ( CLING_CXX_RLTV "${CLING_CXX_RLTV} --gcc-toolchain=${gcctoolchain}" )
endif ( )
endif ( )
endif ( )
2016-08-11 13:12:20 +03:00
endif ( )
if ( NOT CLING_CXX_HEADERS )
if ( CLING_CXX_PATH )
execute_process ( COMMAND ${ CLING_CXX_PATH } -xc++ -E -v /dev/null
O U T P U T _ Q U I E T E R R O R _ V A R I A B L E C L I N G _ C X X _ H E A D E R S )
else ( )
2016-08-23 02:45:23 +03:00
# convert CMAKE_CXX_FLAGS to a list for execute_process
string ( REPLACE " " ";" cling_tmp_arg_list ${ CMAKE_CXX_FLAGS } )
execute_process ( COMMAND ${ CMAKE_CXX_COMPILER } ${ CMAKE_CXX_COMPILER_ARG1 } ${ cling_tmp_arg_list } -xc++ -E -v /dev/null
2016-08-11 13:12:20 +03:00
O U T P U T _ Q U I E T E R R O R _ V A R I A B L E C L I N G _ C X X _ H E A D E R S )
endif ( )
execute_process (
C O M M A N D e c h o $ { C L I N G _ C X X _ H E A D E R S }
C O M M A N D a w k " / ^ #include </,/^End of search/{if (!/^#include </ && !/^End of search/){ print }}"
C O M M A N D g r e p - E " ( c | g ) \ \ + \ \ + "
O U T P U T _ V A R I A B L E C L I N G _ C X X _ H E A D E R S )
stripNewLine ( "${CLING_CXX_HEADERS}" CLING_CXX_HEADERS )
endif ( )
if ( NOT EXISTS ${ CLING_CXX_HEADERS } )
string ( REPLACE "\n" ";" _cxx_inc_paths ${ CLING_CXX_HEADERS } )
foreach ( _cxx_inc_path ${ _cxx_inc_paths } )
string ( STRIP "${_cxx_inc_path}" _cxx_inc_path )
if ( NOT EXISTS ${ _cxx_inc_path } )
set ( _cxx_inc_join "" )
break ( )
endif ( )
if ( _cxx_inc_join )
set ( _cxx_inc_join "${_cxx_inc_join}:${_cxx_inc_path}" )
else ( )
set ( _cxx_inc_join "${_cxx_inc_path}" )
endif ( )
endforeach ( )
set ( CLING_CXX_HEADERS "${_cxx_inc_join}" )
if ( NOT CLING_CXX_HEADERS )
MESSAGE ( WARNING "Cannot determine location of C++ headers for runtime." )
endif ( )
endif ( )
MESSAGE ( STATUS "Cling will look for C++ headers in '${CLING_CXX_HEADERS}' at runtime." )
2017-02-03 14:24:18 +03:00
# In modules builds we 'mount' our own stl modulemap for libstdc++. In order to do this,
# we need to know where is ROOT/cling STL.
if ( cxxmodules )
set_property ( GLOBAL PROPERTY ROOT_CLING_CXX_HEADERS_LOCATION "${CLING_CXX_HEADERS}" )
endif ( cxxmodules )
2016-08-11 13:12:20 +03:00
if ( CLING_CXX_PATH )
MESSAGE ( STATUS "And if not found, will invoke: '${CLING_CXX_PATH}' for them." )
if ( CLING_CXX_RLTV )
MESSAGE ( STATUS "And then fallback to: '${CLING_CXX_RLTV}'" )
2017-02-03 14:25:23 +03:00
# FIXME: We should use file(GENERATE) cmake command.
2016-08-11 13:12:20 +03:00
file ( WRITE ${ CMAKE_CURRENT_BINARY_DIR } /cling-compiledata.h.in
"
#define CLING_CXX_INCL \"${CLING_CXX_HEADERS}\"
#define CLING_CXX_PATH \"${CLING_CXX_PATH} ${CMAKE_CXX_FLAGS_NO_I} ${CMAKE_CXX_FLAGS_${uppercase_CMAKE_BUILD_TYPE}}\"
#define CLING_CXX_RLTV \"${CLING_CXX_RLTV} ${CMAKE_CXX_FLAGS_NO_I} ${CMAKE_CXX_FLAGS_${uppercase_CMAKE_BUILD_TYPE}}\"
2016-08-12 22:54:47 +03:00
#define CLING_INCLUDE_PATHS \"${CLING_INCLUDE_PATHS}\"
2016-08-11 13:12:20 +03:00
" )
else ( )
file ( WRITE ${ CMAKE_CURRENT_BINARY_DIR } /cling-compiledata.h.in
"
#define CLING_CXX_INCL \"${CLING_CXX_HEADERS}\"
#define CLING_CXX_PATH \"${CLING_CXX_PATH} ${CMAKE_CXX_FLAGS_NO_I} ${CMAKE_CXX_FLAGS_${uppercase_CMAKE_BUILD_TYPE}}\"
2016-08-12 22:54:47 +03:00
#define CLING_INCLUDE_PATHS \"${CLING_INCLUDE_PATHS}\"
2016-08-11 13:12:20 +03:00
" )
endif ( )
else ( )
MESSAGE ( STATUS "And if not found, will invoke: '${CLING_CXX_RLTV}' for them." )
file ( WRITE ${ CMAKE_CURRENT_BINARY_DIR } /cling-compiledata.h.in
"
#define CLING_CXX_INCL \"${CLING_CXX_HEADERS}\"
#define CLING_CXX_RLTV \"${CLING_CXX_RLTV} ${CMAKE_CXX_FLAGS_NO_I} ${CMAKE_CXX_FLAGS_${uppercase_CMAKE_BUILD_TYPE}}\"
2016-08-12 22:54:47 +03:00
#define CLING_INCLUDE_PATHS \"${CLING_INCLUDE_PATHS}\"
2016-08-11 13:12:20 +03:00
" )
endif ( )
2016-08-12 22:54:47 +03:00
else ( )
file ( WRITE ${ CMAKE_CURRENT_BINARY_DIR } /cling-compiledata.h.in
"
#define CLING_INCLUDE_PATHS \"${CLING_INCLUDE_PATHS}\"
2016-09-21 00:54:01 +03:00
#define CLING_UCRT_VERSION \"$ENV{UCRTVersion}\"
2016-08-12 22:54:47 +03:00
" )
endif ( )
2016-08-11 13:12:20 +03:00
2016-08-12 22:54:47 +03:00
# Make sure this goes last so so we can pick up any changes that occured
# Also means cling-compiledata.h.in should be edited never cling-compiledata.h
2016-08-11 13:12:20 +03:00
2016-08-12 22:54:47 +03:00
add_custom_command ( OUTPUT ${ CMAKE_CURRENT_BINARY_DIR } /cling-compiledata.h
C O M M A N D $ { C M A K E _ C O M M A N D } - E c o p y _ i f _ d i f f e r e n t
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / c l i n g - c o m p i l e d a t a . h . i n
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / c l i n g - c o m p i l e d a t a . h
M A I N _ D E P E N D E N C Y $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / c l i n g - c o m p i l e d a t a . h . i n
C O M M E N T " U p d a t i n g c l i n g - c o m p i l e d a t a . h " )
2016-08-11 13:12:20 +03:00
2016-08-12 22:54:47 +03:00
add_file_dependencies ( ${ CMAKE_CURRENT_SOURCE_DIR } /CIFactory.cpp
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / c l i n g - c o m p i l e d a t a . h )