summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt47
1 files changed, 43 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bb128d6..0cd52d0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,3 +1,26 @@
+# Clang version information
+
+# Make sure that CMake reconfigures when the version changes.
+configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/VER
+ ${CMAKE_CURRENT_BINARY_DIR}/VER)
+
+set(CLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+set(CLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
+
+# 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}")
+
+# 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 ()
+
macro(add_clang_library name)
set(srcs ${ARGN})
if(MSVC_IDE OR XCODE)
@@ -11,10 +34,27 @@ macro(add_clang_library name)
../../include/clang${dir}/*.def)
set(srcs ${srcs} ${headers})
endif(MSVC_IDE OR XCODE)
- add_library( ${name} ${srcs} )
+ if (SHARED_LIBRARY)
+ set(libkind SHARED)
+ else()
+ set(libkind)
+ endif()
+ add_library( ${name} ${libkind} ${srcs} )
if( LLVM_COMMON_DEPENDS )
add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} )
endif( LLVM_COMMON_DEPENDS )
+ if( LLVM_USED_LIBS )
+ foreach(lib ${LLVM_USED_LIBS})
+ target_link_libraries( ${name} ${lib} )
+ endforeach(lib)
+ endif( LLVM_USED_LIBS )
+ 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 )
add_dependencies(${name} ClangDiagnosticCommon)
if(MSVC)
get_target_property(cflag ${name} COMPILE_FLAGS)
@@ -36,8 +76,6 @@ macro(add_clang_executable name)
set(srcs ${srcs} ${headers})
endif(MSVC_IDE)
add_llvm_executable( ${name} ${srcs} )
- install(TARGETS ${name}
- RUNTIME DESTINATION bin)
endmacro(add_clang_executable)
include_directories(
@@ -57,4 +95,5 @@ add_subdirectory(lib)
add_subdirectory(tools)
# TODO: docs.
-add_subdirectory(test) \ No newline at end of file
+add_subdirectory(test)
+
OpenPOWER on IntegriCloud