blob: bb128d68f2bdb6467b3911b83b9147a5eeedb00a [file] [log] [blame]
Oscar Fuentesd2f4e5e2008-10-26 00:56:18 +00001macro(add_clang_library name)
Cedric Venetfe2f8082008-11-02 16:28:53 +00002 set(srcs ${ARGN})
Ted Kremenekbf5de3f2009-03-25 20:34:07 +00003 if(MSVC_IDE OR XCODE)
Douglas Gregorf5216f22009-06-17 18:31:02 +00004 file( GLOB_RECURSE headers *.h *.td *.def)
Cedric Venetfe2f8082008-11-02 16:28:53 +00005 set(srcs ${srcs} ${headers})
6 string( REGEX MATCHALL "/[^/]+" split_path ${CMAKE_CURRENT_SOURCE_DIR})
7 list( GET split_path -1 dir)
Douglas Gregorf5216f22009-06-17 18:31:02 +00008 file( GLOB_RECURSE headers
9 ../../include/clang${dir}/*.h
10 ../../include/clang${dir}/*.td
11 ../../include/clang${dir}/*.def)
Cedric Venetfe2f8082008-11-02 16:28:53 +000012 set(srcs ${srcs} ${headers})
Ted Kremenekbf5de3f2009-03-25 20:34:07 +000013 endif(MSVC_IDE OR XCODE)
Cedric Venetfe2f8082008-11-02 16:28:53 +000014 add_library( ${name} ${srcs} )
Oscar Fuentesd2f4e5e2008-10-26 00:56:18 +000015 if( LLVM_COMMON_DEPENDS )
16 add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} )
17 endif( LLVM_COMMON_DEPENDS )
Douglas Gregora393e9e2009-03-16 23:06:59 +000018 add_dependencies(${name} ClangDiagnosticCommon)
Cedric Venet1c212a02008-12-13 11:00:04 +000019 if(MSVC)
20 get_target_property(cflag ${name} COMPILE_FLAGS)
21 if(NOT cflag)
22 set(cflag "")
23 endif(NOT cflag)
24 set(cflag "${cflag} /Za")
25 set_target_properties(${name} PROPERTIES COMPILE_FLAGS ${cflag})
26 endif(MSVC)
Oscar Fuentesd2f4e5e2008-10-26 00:56:18 +000027 install(TARGETS ${name}
28 LIBRARY DESTINATION lib
Oscar Fuentes755f3df2009-06-12 02:54:12 +000029 ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
Oscar Fuentesd2f4e5e2008-10-26 00:56:18 +000030endmacro(add_clang_library)
31
32macro(add_clang_executable name)
Cedric Venetfe2f8082008-11-02 16:28:53 +000033 set(srcs ${ARGN})
34 if(MSVC_IDE)
Douglas Gregorf5216f22009-06-17 18:31:02 +000035 file( GLOB_RECURSE headers *.h *.td *.def)
Cedric Venetfe2f8082008-11-02 16:28:53 +000036 set(srcs ${srcs} ${headers})
37 endif(MSVC_IDE)
38 add_llvm_executable( ${name} ${srcs} )
Oscar Fuentesd2f4e5e2008-10-26 00:56:18 +000039 install(TARGETS ${name}
40 RUNTIME DESTINATION bin)
41endmacro(add_clang_executable)
42
43include_directories(
44 ${CMAKE_CURRENT_SOURCE_DIR}/include
Douglas Gregora393e9e2009-03-16 23:06:59 +000045 ${CMAKE_CURRENT_BINARY_DIR}/include
Oscar Fuentesd2f4e5e2008-10-26 00:56:18 +000046 )
47
Chris Lattnerbc6ec752008-11-11 18:39:10 +000048install(DIRECTORY include
49 DESTINATION .
50 PATTERN ".svn" EXCLUDE
51 )
52
Oscar Fuentesd2f4e5e2008-10-26 00:56:18 +000053add_definitions( -D_GNU_SOURCE )
54
Douglas Gregora393e9e2009-03-16 23:06:59 +000055add_subdirectory(include)
Oscar Fuentesd2f4e5e2008-10-26 00:56:18 +000056add_subdirectory(lib)
Daniel Dunbarcbcd98b2009-03-24 02:52:57 +000057add_subdirectory(tools)
Oscar Fuentesd2f4e5e2008-10-26 00:56:18 +000058
59# TODO: docs.
Douglas Gregoreb357b62009-06-05 16:00:31 +000060add_subdirectory(test)