blob: d9c14fbe837a0314f979657af382820923f7b270 [file] [log] [blame]
Oscar Fuentes1bbdd462008-11-14 22:06:14 +00001include(AddFileDependencies)
2
Oscar Fuentes50925fb2008-11-15 02:08:08 +00003
4macro(add_td_sources srcs)
5 file(GLOB tds *.td)
6 if( tds )
7 source_group("TableGen descriptions" FILES ${tds})
8 set_source_files_properties(${tds} PROPERTIES HEADER_FILE_ONLY ON)
9 list(APPEND ${srcs} ${tds})
10 endif()
11endmacro(add_td_sources)
12
13
14macro(add_header_files srcs)
15 file(GLOB hds *.h)
16 if( hds )
17 set_source_files_properties(${hds} PROPERTIES HEADER_FILE_ONLY ON)
18 list(APPEND ${srcs} ${hds})
19 endif()
20endmacro(add_header_files)
21
22
23function(llvm_process_sources OUT_VAR)
Oscar Fuentes1bbdd462008-11-14 22:06:14 +000024 set( sources ${ARGN} )
Oscar Fuentesd442ab82009-11-02 19:11:03 +000025 llvm_check_source_file_list( ${sources} )
Oscar Fuentes1bbdd462008-11-14 22:06:14 +000026 # Create file dependencies on the tablegenned files, if any. Seems
27 # that this is not strictly needed, as dependencies of the .cpp
28 # sources on the tablegenned .inc files are detected and handled,
29 # but just in case...
30 foreach( s ${sources} )
31 set( f ${CMAKE_CURRENT_SOURCE_DIR}/${s} )
32 add_file_dependencies( ${f} ${TABLEGEN_OUTPUT} )
33 endforeach(s)
Oscar Fuentes50925fb2008-11-15 02:08:08 +000034 if( MSVC_IDE )
35 # This adds .td and .h files to the Visual Studio solution:
36 add_td_sources(sources)
37 add_header_files(sources)
38 endif()
Oscar Fuentesf0c55a92010-10-17 02:26:16 +000039
40 # Set common compiler options:
41 if( NOT LLVM_REQUIRES_EH )
42 if( CMAKE_COMPILER_IS_GNUCXX )
43 add_definitions( -fno-exceptions )
Francois Pichetb3614522010-12-04 14:30:22 +000044 elseif( MSVC )
Oscar Fuentes023c6332010-12-31 19:10:49 +000045 string( REGEX REPLACE "[ ^]/EHsc ?" " /EHs-c- " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" )
Francois Pichetb3614522010-12-04 14:30:22 +000046 add_definitions( /D_HAS_EXCEPTIONS=0 )
Oscar Fuentesf0c55a92010-10-17 02:26:16 +000047 endif()
48 endif()
49 if( NOT LLVM_REQUIRES_RTTI )
50 if( CMAKE_COMPILER_IS_GNUCXX )
51 add_definitions( -fno-rtti )
Francois Picheta785a6b2010-12-04 09:42:30 +000052 elseif( MSVC )
Oscar Fuentes023c6332010-12-31 19:10:49 +000053 string( REGEX REPLACE "[ ^]/GR ?" " /GR- " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" )
Oscar Fuentesf0c55a92010-10-17 02:26:16 +000054 endif()
55 endif()
56
Oscar Fuentes50925fb2008-11-15 02:08:08 +000057 set( ${OUT_VAR} ${sources} PARENT_SCOPE )
Oscar Fuentes1bbdd462008-11-14 22:06:14 +000058endfunction(llvm_process_sources)
Oscar Fuentesd442ab82009-11-02 19:11:03 +000059
60
61function(llvm_check_source_file_list)
62 set(listed ${ARGN})
63 file(GLOB globbed *.cpp)
64 foreach(g ${globbed})
65 get_filename_component(fn ${g} NAME)
66 list(FIND listed ${fn} idx)
67 if( idx LESS 0 )
68 message(SEND_ERROR "Found unknown source file ${g}
69Please update ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt\n")
70 endif()
71 endforeach()
72endfunction(llvm_check_source_file_list)