mirror of
https://github.com/nasa/trick.git
synced 2024-12-18 20:57:55 +00:00
cmake scripts do not work for CentOS7 #914
Updated minimum cmake version to 3.1 Added checks in findllvm script to handle old 3.4 LLVM version Added back include directories needed by old LLVM version in ICG.
This commit is contained in:
parent
88149a990d
commit
83338c4957
@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
project(trick)
|
||||
set(TRICK_MAJOR 19)
|
||||
set(TRICK_MINOR 1)
|
||||
|
@ -107,11 +107,14 @@ else()
|
||||
llvm_set(HOST_TARGET host-target)
|
||||
llvm_set(INCLUDE_DIRS includedir true)
|
||||
llvm_set(ROOT_DIR prefix true)
|
||||
llvm_set(ENABLE_ASSERTIONS assertion-mode)
|
||||
|
||||
# The LLVM version string _may_ contain a git/svn suffix, so match only the x.y.z part
|
||||
string(REGEX MATCH "^[0-9]+[.][0-9]+[.][0-9]+" LLVM_VERSION_BASE_STRING "${LLVM_VERSION_STRING}")
|
||||
|
||||
if(NOT ${LLVM_VERSION_STRING} MATCHES "^3\\.4\\..*")
|
||||
llvm_set(ENABLE_ASSERTIONS assertion-mode)
|
||||
endif()
|
||||
|
||||
# Versions below 4.0 do not support components debuginfomsf and demangle
|
||||
if(${LLVM_VERSION_STRING} MATCHES "^3\\..*")
|
||||
list(REMOVE_ITEM LLVM_FIND_COMPONENTS "debuginfomsf" index)
|
||||
@ -125,7 +128,9 @@ else()
|
||||
llvm_set(LDFLAGS ldflags)
|
||||
# In LLVM 3.5+, the system library dependencies (e.g. "-lz") are accessed
|
||||
# using the separate "--system-libs" flag.
|
||||
if(NOT ${LLVM_VERSION_STRING} MATCHES "^3\\.4\\..*")
|
||||
llvm_set(SYSTEM_LIBS system-libs)
|
||||
endif()
|
||||
string(REPLACE "\n" " " LLVM_LDFLAGS "${LLVM_LDFLAGS} ${LLVM_SYSTEM_LIBS}")
|
||||
string(STRIP ${LLVM_LDFLAGS} LLVM_LDFLAGS)
|
||||
llvm_set(LIBRARY_DIRS libdir true)
|
||||
@ -150,10 +155,12 @@ else()
|
||||
|
||||
# Parse LLVM_NATIVE_ARCH manually from LLVMConfig.cmake; including it leads to issues like
|
||||
# https://github.com/ldc-developers/ldc/issues/3079.
|
||||
if(EXISTS "${LLVM_CMAKEDIR}/LLVMConfig.cmake")
|
||||
file(STRINGS "${LLVM_CMAKEDIR}/LLVMConfig.cmake" LLVM_NATIVE_ARCH LIMIT_COUNT 1 REGEX "^set\\(LLVM_NATIVE_ARCH (.+)\\)$")
|
||||
string(REGEX MATCH "set\\(LLVM_NATIVE_ARCH (.+)\\)" LLVM_NATIVE_ARCH "${LLVM_NATIVE_ARCH}")
|
||||
set(LLVM_NATIVE_ARCH ${CMAKE_MATCH_1})
|
||||
message(STATUS "LLVM_NATIVE_ARCH: ${LLVM_NATIVE_ARCH}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# On CMake builds of LLVM, the output of llvm-config --cxxflags does not
|
||||
@ -180,6 +187,7 @@ endif()
|
||||
|
||||
string(REGEX REPLACE "([0-9]+).*" "\\1" LLVM_VERSION_MAJOR "${LLVM_VERSION_STRING}" )
|
||||
string(REGEX REPLACE "[0-9]+\\.([0-9]+).*[A-Za-z]*" "\\1" LLVM_VERSION_MINOR "${LLVM_VERSION_STRING}" )
|
||||
string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+).*[A-Za-z]*" "\\1" LLVM_VERSION_PATCH "${LLVM_VERSION_STRING}" )
|
||||
|
||||
if (${LLVM_VERSION_STRING} VERSION_LESS ${LLVM_FIND_VERSION})
|
||||
message(FATAL_ERROR "Unsupported LLVM version found ${LLVM_VERSION_STRING}. At least version ${LLVM_FIND_VERSION} is required.")
|
||||
|
@ -25,15 +25,14 @@ set ( ICG_SRC
|
||||
|
||||
add_executable( trick-ICG ${ICG_SRC} )
|
||||
target_compile_options( trick-ICG PUBLIC -g -DTRICK_VERSION="${TRICK_MAJOR}.${TRICK_MINOR}.${TRICK_TINY}" -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS)
|
||||
target_compile_options( trick-ICG PUBLIC -DLIBCLANG_MAJOR=${LLVM_VERSION_MAJOR} -DLIBCLANG_MINOR=${LLVM_VERSION_MINOR})
|
||||
target_compile_options( trick-ICG PUBLIC -DEXTERNAL_BUILD)
|
||||
target_compile_options( trick-ICG PUBLIC -DLLVM_HOME="${LLVM_ROOT_DIR}")
|
||||
target_compile_options( trick-ICG PUBLIC -DLIBCLANG_MAJOR=${LLVM_VERSION_MAJOR} -DLIBCLANG_MINOR=${LLVM_VERSION_MINOR} -DLIBCLANG_PATCHLEVEL=${LLVM_VERSION_PATCH})
|
||||
target_include_directories( trick-ICG PUBLIC ${UDUNITS2_INCLUDES} )
|
||||
target_include_directories( trick-ICG PUBLIC ${LLVM_INCLUDE_DIRS} )
|
||||
set_property(SOURCE trick-ICG APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_BINARY_DIR}/include/mongoose/mongoose.h)
|
||||
|
||||
target_link_libraries( trick-ICG
|
||||
${LLVM_LDFLAGS}
|
||||
${LLVM_LIBRARIES}
|
||||
-lclangFrontend
|
||||
-lclangDriver
|
||||
-lclangSerialization
|
||||
@ -44,6 +43,8 @@ target_link_libraries( trick-ICG
|
||||
-lclangAST
|
||||
-lclangLex
|
||||
-lclangBasic
|
||||
${LLVM_LDFLAGS}
|
||||
${LLVM_LIBRARIES}
|
||||
${UDUNITS2_LIBRARIES}
|
||||
)
|
||||
|
||||
|
@ -36,7 +36,6 @@ void HeaderSearchDirs::AddCompilerBuiltInSearchDirs () {
|
||||
// Add clang specific include directory first. Only required on linux systems. :(
|
||||
// This is so that ICG will find clang friendly headers first. gcc headers cause
|
||||
// all kinds of problems. On macs all headers are clang friendly.
|
||||
#ifndef EXTERNAL_BUILD
|
||||
#if __linux
|
||||
std::stringstream icg_dir ;
|
||||
icg_dir << LLVM_HOME << "/lib/clang/" ;
|
||||
@ -49,7 +48,6 @@ void HeaderSearchDirs::AddCompilerBuiltInSearchDirs () {
|
||||
if ( resolved_path != NULL ) {
|
||||
hso.AddPath(resolved_path , clang::frontend::System, IsFramework, IsSysRootRelative);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
fp = popen("${TRICK_HOME}/bin/trick-gte TRICK_CXX" , "r") ;
|
||||
|
Loading…
Reference in New Issue
Block a user