Douglas Gregor | 7f7b748 | 2009-08-23 05:28:29 +0000 | [diff] [blame] | 1 | # Clang version information |
Douglas Gregor | 34d9ffa | 2009-09-16 21:59:05 +0000 | [diff] [blame] | 2 | |
| 3 | # Make sure that CMake reconfigures when the version changes. |
| 4 | configure_file( |
| 5 | ${CMAKE_CURRENT_SOURCE_DIR}/VER |
| 6 | ${CMAKE_CURRENT_BINARY_DIR}/VER) |
| 7 | |
Daniel Dunbar | 91ee77a | 2009-09-17 00:07:10 +0000 | [diff] [blame] | 8 | set(CLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) |
| 9 | set(CLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) |
| 10 | |
Douglas Gregor | 34d9ffa | 2009-09-16 21:59:05 +0000 | [diff] [blame] | 11 | # Compute the Clang version from the contents of VER |
| 12 | file(READ ${CMAKE_CURRENT_SOURCE_DIR}/VER CLANG_VERSION_DATA) |
| 13 | string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION |
| 14 | ${CLANG_VERSION_DATA}) |
| 15 | message(STATUS "Clang version: ${CLANG_VERSION}") |
Douglas Gregor | 7f7b748 | 2009-08-23 05:28:29 +0000 | [diff] [blame] | 16 | |
Douglas Gregor | 9df3faf | 2009-09-18 14:47:57 +0000 | [diff] [blame] | 17 | # Add appropriate flags for GCC |
| 18 | if (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") |
| 22 | endif () |
| 23 | |
Oscar Fuentes | d2f4e5e | 2008-10-26 00:56:18 +0000 | [diff] [blame] | 24 | macro(add_clang_library name) |
Cedric Venet | fe2f808 | 2008-11-02 16:28:53 +0000 | [diff] [blame] | 25 | set(srcs ${ARGN}) |
Ted Kremenek | bf5de3f | 2009-03-25 20:34:07 +0000 | [diff] [blame] | 26 | if(MSVC_IDE OR XCODE) |
Douglas Gregor | f5216f2 | 2009-06-17 18:31:02 +0000 | [diff] [blame] | 27 | file( GLOB_RECURSE headers *.h *.td *.def) |
Cedric Venet | fe2f808 | 2008-11-02 16:28:53 +0000 | [diff] [blame] | 28 | set(srcs ${srcs} ${headers}) |
| 29 | string( REGEX MATCHALL "/[^/]+" split_path ${CMAKE_CURRENT_SOURCE_DIR}) |
| 30 | list( GET split_path -1 dir) |
Douglas Gregor | f5216f2 | 2009-06-17 18:31:02 +0000 | [diff] [blame] | 31 | file( GLOB_RECURSE headers |
| 32 | ../../include/clang${dir}/*.h |
| 33 | ../../include/clang${dir}/*.td |
| 34 | ../../include/clang${dir}/*.def) |
Cedric Venet | fe2f808 | 2008-11-02 16:28:53 +0000 | [diff] [blame] | 35 | set(srcs ${srcs} ${headers}) |
Ted Kremenek | bf5de3f | 2009-03-25 20:34:07 +0000 | [diff] [blame] | 36 | endif(MSVC_IDE OR XCODE) |
Cedric Venet | fe2f808 | 2008-11-02 16:28:53 +0000 | [diff] [blame] | 37 | add_library( ${name} ${srcs} ) |
Oscar Fuentes | d2f4e5e | 2008-10-26 00:56:18 +0000 | [diff] [blame] | 38 | if( LLVM_COMMON_DEPENDS ) |
| 39 | add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} ) |
| 40 | endif( LLVM_COMMON_DEPENDS ) |
Douglas Gregor | a393e9e | 2009-03-16 23:06:59 +0000 | [diff] [blame] | 41 | add_dependencies(${name} ClangDiagnosticCommon) |
Cedric Venet | 1c212a0 | 2008-12-13 11:00:04 +0000 | [diff] [blame] | 42 | 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 Fuentes | d2f4e5e | 2008-10-26 00:56:18 +0000 | [diff] [blame] | 50 | install(TARGETS ${name} |
| 51 | LIBRARY DESTINATION lib |
Oscar Fuentes | 755f3df | 2009-06-12 02:54:12 +0000 | [diff] [blame] | 52 | ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) |
Oscar Fuentes | d2f4e5e | 2008-10-26 00:56:18 +0000 | [diff] [blame] | 53 | endmacro(add_clang_library) |
| 54 | |
| 55 | macro(add_clang_executable name) |
Cedric Venet | fe2f808 | 2008-11-02 16:28:53 +0000 | [diff] [blame] | 56 | set(srcs ${ARGN}) |
| 57 | if(MSVC_IDE) |
Douglas Gregor | f5216f2 | 2009-06-17 18:31:02 +0000 | [diff] [blame] | 58 | file( GLOB_RECURSE headers *.h *.td *.def) |
Cedric Venet | fe2f808 | 2008-11-02 16:28:53 +0000 | [diff] [blame] | 59 | set(srcs ${srcs} ${headers}) |
| 60 | endif(MSVC_IDE) |
| 61 | add_llvm_executable( ${name} ${srcs} ) |
Oscar Fuentes | d2f4e5e | 2008-10-26 00:56:18 +0000 | [diff] [blame] | 62 | endmacro(add_clang_executable) |
| 63 | |
| 64 | include_directories( |
| 65 | ${CMAKE_CURRENT_SOURCE_DIR}/include |
Douglas Gregor | a393e9e | 2009-03-16 23:06:59 +0000 | [diff] [blame] | 66 | ${CMAKE_CURRENT_BINARY_DIR}/include |
Oscar Fuentes | d2f4e5e | 2008-10-26 00:56:18 +0000 | [diff] [blame] | 67 | ) |
| 68 | |
Chris Lattner | bc6ec75 | 2008-11-11 18:39:10 +0000 | [diff] [blame] | 69 | install(DIRECTORY include |
| 70 | DESTINATION . |
| 71 | PATTERN ".svn" EXCLUDE |
| 72 | ) |
| 73 | |
Oscar Fuentes | d2f4e5e | 2008-10-26 00:56:18 +0000 | [diff] [blame] | 74 | add_definitions( -D_GNU_SOURCE ) |
| 75 | |
Douglas Gregor | a393e9e | 2009-03-16 23:06:59 +0000 | [diff] [blame] | 76 | add_subdirectory(include) |
Oscar Fuentes | d2f4e5e | 2008-10-26 00:56:18 +0000 | [diff] [blame] | 77 | add_subdirectory(lib) |
Daniel Dunbar | cbcd98b | 2009-03-24 02:52:57 +0000 | [diff] [blame] | 78 | add_subdirectory(tools) |
Oscar Fuentes | d2f4e5e | 2008-10-26 00:56:18 +0000 | [diff] [blame] | 79 | |
| 80 | # TODO: docs. |
Douglas Gregor | 291fbde | 2009-09-15 22:30:13 +0000 | [diff] [blame] | 81 | add_subdirectory(test) |
| 82 | |