2009-08-23 13:28:29 +08:00
|
|
|
# Clang version information
|
2009-09-17 05:59:05 +08:00
|
|
|
|
|
|
|
# Make sure that CMake reconfigures when the version changes.
|
|
|
|
configure_file(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/VER
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/VER)
|
|
|
|
|
2009-09-17 08:07:10 +08:00
|
|
|
set(CLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
set(CLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
|
2009-09-17 05:59:05 +08:00
|
|
|
# Compute the Clang version from the contents of VER
|
|
|
|
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/VER CLANG_VERSION_DATA)
|
|
|
|
string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION
|
|
|
|
${CLANG_VERSION_DATA})
|
|
|
|
message(STATUS "Clang version: ${CLANG_VERSION}")
|
2009-08-23 13:28:29 +08:00
|
|
|
|
2009-09-18 22:47:57 +08:00
|
|
|
# Add appropriate flags for GCC
|
|
|
|
if (CMAKE_COMPILER_IS_GNUCXX)
|
|
|
|
# FIXME: Turn off exceptions, RTTI:
|
|
|
|
# -fno-exceptions -fno-rtti
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common -Woverloaded-virtual -pedantic -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings")
|
|
|
|
endif ()
|
|
|
|
|
2008-10-26 08:56:18 +08:00
|
|
|
macro(add_clang_library name)
|
2008-11-03 00:28:53 +08:00
|
|
|
set(srcs ${ARGN})
|
2009-03-26 04:34:07 +08:00
|
|
|
if(MSVC_IDE OR XCODE)
|
2009-06-18 02:31:02 +08:00
|
|
|
file( GLOB_RECURSE headers *.h *.td *.def)
|
2008-11-03 00:28:53 +08:00
|
|
|
set(srcs ${srcs} ${headers})
|
|
|
|
string( REGEX MATCHALL "/[^/]+" split_path ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
list( GET split_path -1 dir)
|
2009-06-18 02:31:02 +08:00
|
|
|
file( GLOB_RECURSE headers
|
|
|
|
../../include/clang${dir}/*.h
|
|
|
|
../../include/clang${dir}/*.td
|
|
|
|
../../include/clang${dir}/*.def)
|
2008-11-03 00:28:53 +08:00
|
|
|
set(srcs ${srcs} ${headers})
|
2009-03-26 04:34:07 +08:00
|
|
|
endif(MSVC_IDE OR XCODE)
|
2009-09-25 14:35:15 +08:00
|
|
|
if (SHARED_LIBRARY)
|
|
|
|
set(libkind SHARED)
|
|
|
|
else()
|
|
|
|
set(libkind)
|
|
|
|
endif()
|
|
|
|
add_library( ${name} ${libkind} ${srcs} )
|
2008-10-26 08:56:18 +08:00
|
|
|
if( LLVM_COMMON_DEPENDS )
|
|
|
|
add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} )
|
|
|
|
endif( LLVM_COMMON_DEPENDS )
|
2009-09-25 14:35:15 +08:00
|
|
|
if( LLVM_USED_LIBS )
|
|
|
|
foreach(lib ${LLVM_USED_LIBS})
|
|
|
|
target_link_libraries( ${name} ${lib} )
|
|
|
|
endforeach(lib)
|
|
|
|
endif( LLVM_USED_LIBS )
|
2009-10-11 20:22:00 +08:00
|
|
|
if( LLVM_LINK_COMPONENTS )
|
|
|
|
llvm_config(${name} ${LLVM_LINK_COMPONENTS})
|
|
|
|
endif( LLVM_LINK_COMPONENTS )
|
|
|
|
get_system_libs(llvm_system_libs)
|
|
|
|
if( llvm_system_libs )
|
|
|
|
target_link_libraries(${name} ${llvm_system_libs})
|
|
|
|
endif( llvm_system_libs )
|
2009-03-17 07:06:59 +08:00
|
|
|
add_dependencies(${name} ClangDiagnosticCommon)
|
2008-12-13 19:00:04 +08:00
|
|
|
if(MSVC)
|
|
|
|
get_target_property(cflag ${name} COMPILE_FLAGS)
|
|
|
|
if(NOT cflag)
|
|
|
|
set(cflag "")
|
|
|
|
endif(NOT cflag)
|
|
|
|
set(cflag "${cflag} /Za")
|
|
|
|
set_target_properties(${name} PROPERTIES COMPILE_FLAGS ${cflag})
|
|
|
|
endif(MSVC)
|
2008-10-26 08:56:18 +08:00
|
|
|
install(TARGETS ${name}
|
2009-10-28 03:42:21 +08:00
|
|
|
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
|
2009-06-12 10:54:12 +08:00
|
|
|
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
|
2008-10-26 08:56:18 +08:00
|
|
|
endmacro(add_clang_library)
|
|
|
|
|
|
|
|
macro(add_clang_executable name)
|
2008-11-03 00:28:53 +08:00
|
|
|
set(srcs ${ARGN})
|
|
|
|
if(MSVC_IDE)
|
2009-06-18 02:31:02 +08:00
|
|
|
file( GLOB_RECURSE headers *.h *.td *.def)
|
2008-11-03 00:28:53 +08:00
|
|
|
set(srcs ${srcs} ${headers})
|
|
|
|
endif(MSVC_IDE)
|
|
|
|
add_llvm_executable( ${name} ${srcs} )
|
2008-10-26 08:56:18 +08:00
|
|
|
endmacro(add_clang_executable)
|
|
|
|
|
|
|
|
include_directories(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
2009-03-17 07:06:59 +08:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/include
|
2008-10-26 08:56:18 +08:00
|
|
|
)
|
|
|
|
|
2009-10-28 03:59:34 +08:00
|
|
|
install(DIRECTORY include/
|
|
|
|
DESTINATION include
|
|
|
|
FILES_MATCHING
|
|
|
|
PATTERN "*.def"
|
|
|
|
PATTERN "*.h"
|
|
|
|
PATTERN "*.td"
|
2008-11-12 02:39:10 +08:00
|
|
|
PATTERN ".svn" EXCLUDE
|
|
|
|
)
|
|
|
|
|
2010-04-01 22:24:41 +08:00
|
|
|
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/
|
|
|
|
DESTINATION include
|
|
|
|
FILES_MATCHING
|
|
|
|
PATTERN "*.inc"
|
|
|
|
)
|
|
|
|
|
2008-10-26 08:56:18 +08:00
|
|
|
add_definitions( -D_GNU_SOURCE )
|
|
|
|
|
2009-11-17 17:32:51 +08:00
|
|
|
option(CLANG_BUILD_EXAMPLES "Build CLANG example programs." OFF)
|
|
|
|
if(CLANG_BUILD_EXAMPLES)
|
|
|
|
add_subdirectory(examples)
|
|
|
|
endif ()
|
|
|
|
|
2009-03-17 07:06:59 +08:00
|
|
|
add_subdirectory(include)
|
2008-10-26 08:56:18 +08:00
|
|
|
add_subdirectory(lib)
|
2009-03-24 10:52:57 +08:00
|
|
|
add_subdirectory(tools)
|
2008-10-26 08:56:18 +08:00
|
|
|
|
|
|
|
# TODO: docs.
|
2009-09-16 06:30:13 +08:00
|
|
|
add_subdirectory(test)
|
|
|
|
|