blob: 9ce07692aa2d13e4192fd0d321714286d976a8f3 [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
Daniel Dunbar91ee77a2009-09-17 00:07:10 +00008set(CLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
9set(CLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
10
Douglas Gregor34d9ffa2009-09-16 21:59:05 +000011# Compute the Clang version from the contents of VER
12file(READ ${CMAKE_CURRENT_SOURCE_DIR}/VER CLANG_VERSION_DATA)
13string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION
14 ${CLANG_VERSION_DATA})
15message(STATUS "Clang version: ${CLANG_VERSION}")
Douglas Gregor7f7b7482009-08-23 05:28:29 +000016
Douglas Gregor9df3faf2009-09-18 14:47:57 +000017# Add appropriate flags for GCC
18if (CMAKE_COMPILER_IS_GNUCXX)
19 # FIXME: Turn off exceptions, RTTI:
20 # -fno-exceptions -fno-rtti
21 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common -Woverloaded-virtual -pedantic -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings")
22endif ()
23
Oscar Fuentesd2f4e5e2008-10-26 00:56:18 +000024macro(add_clang_library name)
Cedric Venetfe2f8082008-11-02 16:28:53 +000025 set(srcs ${ARGN})
Ted Kremenekbf5de3f2009-03-25 20:34:07 +000026 if(MSVC_IDE OR XCODE)
Douglas Gregorf5216f22009-06-17 18:31:02 +000027 file( GLOB_RECURSE headers *.h *.td *.def)
Cedric Venetfe2f8082008-11-02 16:28:53 +000028 set(srcs ${srcs} ${headers})
29 string( REGEX MATCHALL "/[^/]+" split_path ${CMAKE_CURRENT_SOURCE_DIR})
30 list( GET split_path -1 dir)
Douglas Gregorf5216f22009-06-17 18:31:02 +000031 file( GLOB_RECURSE headers
32 ../../include/clang${dir}/*.h
33 ../../include/clang${dir}/*.td
34 ../../include/clang${dir}/*.def)
Cedric Venetfe2f8082008-11-02 16:28:53 +000035 set(srcs ${srcs} ${headers})
Ted Kremenekbf5de3f2009-03-25 20:34:07 +000036 endif(MSVC_IDE OR XCODE)
Cedric Venetfe2f8082008-11-02 16:28:53 +000037 add_library( ${name} ${srcs} )
Oscar Fuentesd2f4e5e2008-10-26 00:56:18 +000038 if( LLVM_COMMON_DEPENDS )
39 add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} )
40 endif( LLVM_COMMON_DEPENDS )
Douglas Gregora393e9e2009-03-16 23:06:59 +000041 add_dependencies(${name} ClangDiagnosticCommon)
Cedric Venet1c212a02008-12-13 11:00:04 +000042 if(MSVC)
43 get_target_property(cflag ${name} COMPILE_FLAGS)
44 if(NOT cflag)
45 set(cflag "")
46 endif(NOT cflag)
47 set(cflag "${cflag} /Za")
48 set_target_properties(${name} PROPERTIES COMPILE_FLAGS ${cflag})
49 endif(MSVC)
Oscar Fuentesd2f4e5e2008-10-26 00:56:18 +000050 install(TARGETS ${name}
51 LIBRARY DESTINATION lib
Oscar Fuentes755f3df2009-06-12 02:54:12 +000052 ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
Oscar Fuentesd2f4e5e2008-10-26 00:56:18 +000053endmacro(add_clang_library)
54
55macro(add_clang_executable name)
Cedric Venetfe2f8082008-11-02 16:28:53 +000056 set(srcs ${ARGN})
57 if(MSVC_IDE)
Douglas Gregorf5216f22009-06-17 18:31:02 +000058 file( GLOB_RECURSE headers *.h *.td *.def)
Cedric Venetfe2f8082008-11-02 16:28:53 +000059 set(srcs ${srcs} ${headers})
60 endif(MSVC_IDE)
61 add_llvm_executable( ${name} ${srcs} )
Oscar Fuentesd2f4e5e2008-10-26 00:56:18 +000062endmacro(add_clang_executable)
63
64include_directories(
65 ${CMAKE_CURRENT_SOURCE_DIR}/include
Douglas Gregora393e9e2009-03-16 23:06:59 +000066 ${CMAKE_CURRENT_BINARY_DIR}/include
Oscar Fuentesd2f4e5e2008-10-26 00:56:18 +000067 )
68
Chris Lattnerbc6ec752008-11-11 18:39:10 +000069install(DIRECTORY include
70 DESTINATION .
71 PATTERN ".svn" EXCLUDE
72 )
73
Oscar Fuentesd2f4e5e2008-10-26 00:56:18 +000074add_definitions( -D_GNU_SOURCE )
75
Douglas Gregora393e9e2009-03-16 23:06:59 +000076add_subdirectory(include)
Oscar Fuentesd2f4e5e2008-10-26 00:56:18 +000077add_subdirectory(lib)
Daniel Dunbarcbcd98b2009-03-24 02:52:57 +000078add_subdirectory(tools)
Oscar Fuentesd2f4e5e2008-10-26 00:56:18 +000079
80# TODO: docs.
Douglas Gregor291fbde2009-09-15 22:30:13 +000081add_subdirectory(test)
82