blob: 4dedcfd6fd8477ddd1a3a7085d1948ae3fe8ebe3 [file] [log] [blame]
Douglas Gregor7f7b7482009-08-23 05:28:29 +00001# Clang version information
Douglas Gregor34d9ffa2009-09-16 21:59:05 +00002
3# Make sure that CMake reconfigures when the version changes.
4configure_file(
5 ${CMAKE_CURRENT_SOURCE_DIR}/VER
6 ${CMAKE_CURRENT_BINARY_DIR}/VER)
7
8# Compute the Clang version from the contents of VER
9file(READ ${CMAKE_CURRENT_SOURCE_DIR}/VER CLANG_VERSION_DATA)
10string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION
11 ${CLANG_VERSION_DATA})
12message(STATUS "Clang version: ${CLANG_VERSION}")
Douglas Gregor7f7b7482009-08-23 05:28:29 +000013
Oscar Fuentesd2f4e5e2008-10-26 00:56:18 +000014macro(add_clang_library name)
Cedric Venetfe2f8082008-11-02 16:28:53 +000015 set(srcs ${ARGN})
Ted Kremenekbf5de3f2009-03-25 20:34:07 +000016 if(MSVC_IDE OR XCODE)
Douglas Gregorf5216f22009-06-17 18:31:02 +000017 file( GLOB_RECURSE headers *.h *.td *.def)
Cedric Venetfe2f8082008-11-02 16:28:53 +000018 set(srcs ${srcs} ${headers})
19 string( REGEX MATCHALL "/[^/]+" split_path ${CMAKE_CURRENT_SOURCE_DIR})
20 list( GET split_path -1 dir)
Douglas Gregorf5216f22009-06-17 18:31:02 +000021 file( GLOB_RECURSE headers
22 ../../include/clang${dir}/*.h
23 ../../include/clang${dir}/*.td
24 ../../include/clang${dir}/*.def)
Cedric Venetfe2f8082008-11-02 16:28:53 +000025 set(srcs ${srcs} ${headers})
Ted Kremenekbf5de3f2009-03-25 20:34:07 +000026 endif(MSVC_IDE OR XCODE)
Cedric Venetfe2f8082008-11-02 16:28:53 +000027 add_library( ${name} ${srcs} )
Oscar Fuentesd2f4e5e2008-10-26 00:56:18 +000028 if( LLVM_COMMON_DEPENDS )
29 add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} )
30 endif( LLVM_COMMON_DEPENDS )
Douglas Gregora393e9e2009-03-16 23:06:59 +000031 add_dependencies(${name} ClangDiagnosticCommon)
Cedric Venet1c212a02008-12-13 11:00:04 +000032 if(MSVC)
33 get_target_property(cflag ${name} COMPILE_FLAGS)
34 if(NOT cflag)
35 set(cflag "")
36 endif(NOT cflag)
37 set(cflag "${cflag} /Za")
38 set_target_properties(${name} PROPERTIES COMPILE_FLAGS ${cflag})
39 endif(MSVC)
Oscar Fuentesd2f4e5e2008-10-26 00:56:18 +000040 install(TARGETS ${name}
41 LIBRARY DESTINATION lib
Oscar Fuentes755f3df2009-06-12 02:54:12 +000042 ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
Oscar Fuentesd2f4e5e2008-10-26 00:56:18 +000043endmacro(add_clang_library)
44
45macro(add_clang_executable name)
Cedric Venetfe2f8082008-11-02 16:28:53 +000046 set(srcs ${ARGN})
47 if(MSVC_IDE)
Douglas Gregorf5216f22009-06-17 18:31:02 +000048 file( GLOB_RECURSE headers *.h *.td *.def)
Cedric Venetfe2f8082008-11-02 16:28:53 +000049 set(srcs ${srcs} ${headers})
50 endif(MSVC_IDE)
51 add_llvm_executable( ${name} ${srcs} )
Oscar Fuentesd2f4e5e2008-10-26 00:56:18 +000052endmacro(add_clang_executable)
53
54include_directories(
55 ${CMAKE_CURRENT_SOURCE_DIR}/include
Douglas Gregora393e9e2009-03-16 23:06:59 +000056 ${CMAKE_CURRENT_BINARY_DIR}/include
Oscar Fuentesd2f4e5e2008-10-26 00:56:18 +000057 )
58
Chris Lattnerbc6ec752008-11-11 18:39:10 +000059install(DIRECTORY include
60 DESTINATION .
61 PATTERN ".svn" EXCLUDE
62 )
63
Oscar Fuentesd2f4e5e2008-10-26 00:56:18 +000064add_definitions( -D_GNU_SOURCE )
65
Douglas Gregora393e9e2009-03-16 23:06:59 +000066add_subdirectory(include)
Oscar Fuentesd2f4e5e2008-10-26 00:56:18 +000067add_subdirectory(lib)
Daniel Dunbarcbcd98b2009-03-24 02:52:57 +000068add_subdirectory(tools)
Oscar Fuentesd2f4e5e2008-10-26 00:56:18 +000069
70# TODO: docs.
Douglas Gregor291fbde2009-09-15 22:30:13 +000071add_subdirectory(test)
72