diff --git a/CMakeLists.txt b/CMakeLists.txt index 93ff707b..06a1d580 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,18 +14,23 @@ include(UseJava) find_package(Java REQUIRED) find_package(BISON REQUIRED) find_package(FLEX REQUIRED) -find_package(SWIG REQUIRED) +find_package(LLVM 3.4 REQUIRED) +find_package(Perl REQUIRED) find_package(PythonInterp REQUIRED) find_package(PythonLibs REQUIRED) +find_package(SWIG REQUIRED) +find_package(Tee REQUIRED) find_package(UDUNITS2 REQUIRED) -find_package(LLVM REQUIRED) find_package(HDF5) find_package(GSL) -set(ENV{TRICK_ICG_EXCLUDE} ${CMAKE_CURRENT_BINARY_DIR}/include/mongoose) add_definitions( -DTRICK_VER=${TRICK_MAJOR} ) add_definitions( -DUSE_ER7_UTILS_INTEGRATORS) +if(GSL_FOUND) + add_definitions( -D_HAVE_GSL) +endif() + file(COPY bin DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) file(COPY include DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) file(COPY libexec DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) @@ -37,6 +42,8 @@ file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lex_yacc) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mongoose) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/swig) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/share/trick/makefiles/config_user.mk.in ${CMAKE_CURRENT_BINARY_DIR}/share/trick/makefiles/config_user.mk) + file(GLOB_RECURSE ER7_UTIL_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/trick_source/er7_utils ${CMAKE_CURRENT_SOURCE_DIR}/trick_source/er7_utils/*.hh) foreach ( infile ${ER7_UTIL_HEADERS} ) get_filename_component(dir ${infile} DIRECTORY) @@ -91,7 +98,7 @@ set ( ICG_SRC ) add_definitions( -g -DTRICK_VERSION="${TRICK_MAJOR}.${TRICK_MINOR}.${TRICK_TINY}" -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS) -#add_definitions( -DLIBCLANG_MAJOR=${LLVM_FIND_VERSION_MAJOR} -DLIBCLANG_MINOR=${LLVM_FIND_VERSION_MINOR}) +add_definitions( -DLIBCLANG_MAJOR=${LLVM_VERSION_MAJOR} -DLIBCLANG_MINOR=${LLVM_VERSION_MINOR}) add_definitions( -DLIBCLANG_MAJOR=7 -DLIBCLANG_MINOR=0) add_executable( trick-ICG ${ICG_SRC} ) @@ -102,7 +109,7 @@ set_property(SOURCE trick-ICG APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_CURRENT_BIN target_link_libraries( trick-ICG ${LLVM_LDFLAGS} - ${LLVM_MODULE_LIBS} + ${LLVM_LIBRARIES} -lclangFrontend -lclangDriver -lclangSerialization @@ -572,13 +579,6 @@ set( TRICK_UTILS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/trick_source/trick_utils/units/src/units_conv ) -set( SWIG_SRC - ${CMAKE_CURRENT_BINARY_DIR}/swig/sim_services_wrap - ${CMAKE_CURRENT_BINARY_DIR}/swig/swig_double_wrap - ${CMAKE_CURRENT_BINARY_DIR}/swig/swig_int_wrap - ${CMAKE_CURRENT_BINARY_DIR}/swig//swig_ref_wrap -) - set( IO_SRC ${CMAKE_CURRENT_BINARY_DIR}/io_src/class_map.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_ABM_Integrator.cpp @@ -683,42 +683,20 @@ set( IO_SRC ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_WebServer.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_WebSocketSession.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_Zeroconf.cpp - ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_attributes.cpp - ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_dllist.cpp - ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_io_alloc.cpp - ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_lqueue.cpp - ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_lstack.cpp - ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_message_type.cpp - ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_mm_error.cpp - ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_ms_sim_mode.cpp - ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_parameter_types.cpp - ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_rand_generator.cpp - ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_reference.cpp - ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_reference_frame.cpp - ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_regula_falsi.cpp - ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_sim_mode.cpp - ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_tc.cpp - ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_time_offset.cpp - ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_trick_error_hndlr.cpp - ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_tsm.cpp - ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_units_conv.cpp - ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_value.cpp - ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_var.cpp - ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_variable_server_sync_types.cpp - ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_wave_form.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_abm4_first_order_ode_integrator.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_abm4_integrator_constructor.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_abm4_second_order_ode_integrator.cpp + ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_attributes.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_base_integration_group.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_beeman_integrator_constructor.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_beeman_second_order_ode_integrator.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_bogus_integration_controls.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_deletable.cpp + ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_dllist.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_euler_first_order_ode_integrator.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_euler_integrator_constructor.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_euler_second_order_ode_integrator.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_first_order_ode_integrator.cpp - ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_first_order_ode_integrator.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_generalized_position_derivative.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_integrable_object.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_integration_controls.cpp @@ -730,19 +708,30 @@ set( IO_SRC ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_integrator_result.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_integrator_result_merger.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_integrator_result_merger_container.cpp + ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_io_alloc.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_left_quaternion_functions.cpp + ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_lqueue.cpp + ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_lstack.cpp + ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_message_type.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_mm4_integrator_constructor.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_mm4_second_order_ode_integrator.cpp + ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_mm_error.cpp + ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_ms_sim_mode.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_n_choose_m.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_nl2_integrator_constructor.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_nl2_second_order_ode_integrator.cpp + ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_parameter_types.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_position_verlet_integrator_constructor.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_position_verlet_second_order_ode_integrator.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_priming_first_order_ode_integrator.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_priming_integration_controls.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_priming_integrator_constructor.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_priming_second_order_ode_integrator.cpp + ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_rand_generator.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_ratio128.cpp + ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_reference.cpp + ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_reference_frame.cpp + ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_regula_falsi.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_rk2_heun_first_order_ode_integrator.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_rk2_heun_integrator_constructor.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_rk2_heun_second_order_ode_integrator.cpp @@ -763,17 +752,28 @@ set( IO_SRC ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_rkg4_integrator_constructor.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_rkg4_second_order_ode_integrator.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_second_order_ode_integrator.cpp - ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_second_order_ode_integrator.cpp + ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_sim_mode.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_single_cycle_integration_controls.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_standard_integration_controls.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_state_integrator.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_symplectic_euler_integrator_constructor.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_symplectic_euler_second_order_ode_integrator.cpp + ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_tc.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_time_interface.cpp + ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_time_offset.cpp + ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_trick_error_hndlr.cpp + ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_trick_first_order_ode_integrator.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_trick_integrator.cpp + ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_trick_second_order_ode_integrator.cpp + ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_tsm.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_uint128.cpp + ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_units_conv.cpp + ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_value.cpp + ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_var.cpp + ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_variable_server_sync_types.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_velocity_verlet_integrator_constructor.cpp ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_velocity_verlet_second_order_ode_integrator.cpp + ${CMAKE_CURRENT_BINARY_DIR}/io_src/io_wave_form.cpp ) set( ER7_UTILS_SRC @@ -845,13 +845,35 @@ set( ER7_UTILS_SRC trick_source/er7_utils/trick/integration/src/trick_integrator ) -set(ENV{TRICK_HOME} ${CMAKE_CURRENT_SOURCE_DIR}/../include) +set(ENV{TRICK_ICG_EXCLUDE} ${CMAKE_CURRENT_BINARY_DIR}/include/mongoose) set(ICG_FLAGS -I${CMAKE_CURRENT_BINARY_DIR}/include -I${CMAKE_CURRENT_BINARY_DIR}/include/trick/compat -I${UDUNITS2_INCLUDES} -DTRICK_VER=${TRICK_MAJOR} -DUSE_ER7_UTILS_INTEGRATORS) add_custom_command(OUTPUT ${IO_SRC} - COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/trick-ICG -force -sim_services -m -n -o ${CMAKE_CURRENT_BINARY_DIR}/io_src ${ICG_FLAGS} ${CMAKE_CURRENT_BINARY_DIR}/include/trick/files_to_ICG.hh + COMMAND TRICK_ICG_EXCLUDE=${CMAKE_CURRENT_BINARY_DIR}/include/mongoose ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/trick-ICG -force -sim_services -m -n -o ${CMAKE_CURRENT_BINARY_DIR}/io_src ${ICG_FLAGS} ${CMAKE_CURRENT_BINARY_DIR}/include/trick/files_to_ICG.hh DEPENDS trick-ICG ) +set( SWIG_SRC + ${CMAKE_CURRENT_BINARY_DIR}/swig/sim_services_wrap + ${CMAKE_CURRENT_BINARY_DIR}/swig/swig_double_wrap + ${CMAKE_CURRENT_BINARY_DIR}/swig/swig_int_wrap + ${CMAKE_CURRENT_BINARY_DIR}/swig//swig_ref_wrap +) + +set( SWIG_SRC_BASENAME + sim_services + swig_double + swig_int + swig_ref +) + +set(SWIG_FLAGS -DUSE_ER7_UTILS_INTEGRATORS -D_HAVE_GSL) +foreach ( infile ${SWIG_SRC_BASENAME} ) + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/swig/${infile}_wrap.cpp + COMMAND ${SWIG_EXECUTABLE} ${SWIG_FLAGS} -I${CMAKE_CURRENT_SOURCE_DIR}/trick_source -I${CMAKE_CURRENT_SOURCE_DIR}/include -I${CMAKE_CURRENT_SOURCE_DIR} -c++ -python -includeall -ignoremissing -w201,362,389,451 -o $@ -outdir ${CMAKE_CURRENT_BINARY_DIR}/swig ${CMAKE_CURRENT_SOURCE_DIR}/trick_source/trick_swig/${infile}.i + ) +endforeach(infile) + + add_library( trick STATIC ${SS_SRC} ${LEX_YACC_SRC} ${TRICK_UTILS_SRC} ${IO_SRC} ${ER7_UTILS_SRC} ${SWIG_SRC}) target_include_directories( trick PUBLIC ${PYTHON_INCLUDE_DIRS} ) @@ -882,19 +904,6 @@ target_include_directories( trick PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/trick_sourc target_include_directories( trick PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/trick_source/er7_utils/trick/include) target_include_directories( trick PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/trick_source/er7_utils/trick/integration/include) -set( SWIG_SRC_BASENAME - sim_services - swig_double - swig_int - swig_ref -) - -foreach ( infile ${SWIG_SRC_BASENAME} ) - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/swig/${infile}_wrap.cpp - COMMAND ${SWIG_EXECUTABLE} -DUSE_ER7_UTILS_INTEGRATORS -I${CMAKE_CURRENT_SOURCE_DIR}/trick_source -I${CMAKE_CURRENT_SOURCE_DIR}/include -I${CMAKE_CURRENT_SOURCE_DIR} -c++ -python -includeall -ignoremissing -w201,362,389,451 -o $@ -outdir ${CMAKE_CURRENT_BINARY_DIR}/swig ${CMAKE_CURRENT_SOURCE_DIR}/trick_source/trick_swig/${infile}.i - ) -endforeach(infile) - ############################################################### # Java libraries ############################################################### diff --git a/CMakeModules/FindLLVM.cmake b/CMakeModules/FindLLVM.cmake index f882589d..a4e66a49 100644 --- a/CMakeModules/FindLLVM.cmake +++ b/CMakeModules/FindLLVM.cmake @@ -1,130 +1,193 @@ -# Find the native LLVM includes and library +# - Find LLVM headers and libraries. +# This module locates LLVM and adapts the llvm-config output for use with +# CMake. # -# LLVM_INCLUDE_DIR - where to find llvm include files -# LLVM_LIBRARY_DIR - where to find llvm libs -# LLVM_CFLAGS - llvm compiler flags -# LLVM_LDFLAGS - llvm linker flags -# LLVM_MODULE_LIBS - list of llvm libs for working with modules. -# LLVM_FOUND - True if llvm found. -if (LLVM_INSTALL_DIR) - find_program(LLVM_CONFIG_EXECUTABLE - NAMES llvm-config-37 llvm-config-3.7 llvm-config-36 llvm-config-3.6 llvm-config-38 llvm-config-3.8 llvm-config-39 llvm-config-3.9 llvm-config llvm-config-35 llvm-config-3.5 llvm-config-34 llvm-config-3.4 - DOC "llvm-config executable" - PATHS ${LLVM_INSTALL_DIR} NO_DEFAULT_PATH) -else (LLVM_INSTALL_DIR) - find_program(LLVM_CONFIG_EXECUTABLE - NAMES llvm-config-37 llvm-config-3.7 llvm-config-36 llvm-config-3.6 llvm-config-38 llvm-config-3.8 llvm-config-39 llvm-config-3.9 llvm-config llvm-config-35 llvm-config-3.5 llvm-config-34 llvm-config-3.4 - DOC "llvm-config executable") -endif (LLVM_INSTALL_DIR) +# A given list of COMPONENTS is passed to llvm-config. +# +# The following variables are defined: +# LLVM_FOUND - true if LLVM was found +# LLVM_CXXFLAGS - C++ compiler flags for files that include LLVM headers. +# LLVM_HOST_TARGET - Target triple used to configure LLVM. +# LLVM_INCLUDE_DIRS - Directory containing LLVM include files. +# LLVM_LDFLAGS - Linker flags to add when linking against LLVM +# (includes -LLLVM_LIBRARY_DIRS). +# LLVM_LIBRARIES - Full paths to the library files to link against. +# LLVM_LIBRARY_DIRS - Directory containing LLVM libraries. +# LLVM_NATIVE_ARCH - Backend corresponding to LLVM_HOST_TARGET, e.g., +# X86 for x86_64 and i686 hosts. +# LLVM_ROOT_DIR - The root directory of the LLVM installation. +# llvm-config is searched for in ${LLVM_ROOT_DIR}/bin. +# LLVM_VERSION_MAJOR - Major version of LLVM. +# LLVM_VERSION_MINOR - Minor version of LLVM. +# LLVM_VERSION_STRING - Full LLVM version string (e.g. 6.0.0svn). +# LLVM_VERSION_BASE_STRING - Base LLVM version string without git/svn suffix (e.g. 6.0.0). +# +# Note: The variable names were chosen in conformance with the offical CMake +# guidelines, see ${CMAKE_ROOT}/Modules/readme.txt. -if (LLVM_CONFIG_EXECUTABLE) - message(STATUS "LLVM llvm-config found at: ${LLVM_CONFIG_EXECUTABLE}") -else (LLVM_CONFIG_EXECUTABLE) - message(FATAL_ERROR "Could NOT find LLVM executable, please add -DLLVM_INSTALL_DIR=/path/to/llvm-config/ in cmake command") -endif (LLVM_CONFIG_EXECUTABLE) -execute_process( - COMMAND ${LLVM_CONFIG_EXECUTABLE} --version - OUTPUT_VARIABLE LLVM_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE -) -string(REGEX REPLACE "([0-9])\\.([0-9]*).*" "\\1\\2" LLVM_VERSION_NODOT ${LLVM_VERSION}) -string(REGEX REPLACE "([0-9])\\.([0-9]*).*" "\\1.\\2" LLVM_VERSION_NOPATCH ${LLVM_VERSION}) +# Try suffixed versions to pick up the newest LLVM install available on Debian +# derivatives. +# We also want an user-specified LLVM_ROOT_DIR to take precedence over the +# system default locations such as /usr/local/bin. Executing find_program() +# multiples times is the approach recommended in the docs. +set(llvm_config_names llvm-config-9.0 llvm-config90 + llvm-config-8.0 llvm-config80 + llvm-config-7.0 llvm-config70 + llvm-config-6.0 llvm-config60 + llvm-config-5.0 llvm-config50 + llvm-config-4.0 llvm-config40 + llvm-config-3.9 llvm-config39 + llvm-config) +find_program(LLVM_CONFIG + NAMES ${llvm_config_names} + PATHS ${LLVM_ROOT_DIR}/bin NO_DEFAULT_PATH + DOC "Path to llvm-config tool.") +find_program(LLVM_CONFIG NAMES ${llvm_config_names}) -if (LLVM_FIND_VERSION_MAJOR AND LLVM_FIND_VERSION_MINOR) - SET(LLVM_FIND_VERSION_NODOT "${LLVM_FIND_VERSION_MAJOR}${LLVM_FIND_VERSION_MINOR}") - if (LLVM_VERSION_NODOT VERSION_LESS LLVM_FIND_VERSION_NODOT) - message(FATAL_ERROR "imcompatible LLVM version ${LLVM_VERSION} required ${LLVM_FIND_VERSION}") - else (LLVM_VERSION_NODOT VERSION_LESS LLVM_FIND_VERSION_NODOT) - if (LLVM_VERSION_NODOT VERSION_EQUAL LLVM_FIND_VERSION_NODOT) - message(STATUS "find stable LLVM version ${LLVM_VERSION}") - else (LLVM_VERSION_NODOT VERSION_EQUAL LLVM_FIND_VERSION_NODOT) - message(STATUS "find unstable LLVM version ${LLVM_VERSION}") - endif (LLVM_VERSION_NODOT VERSION_EQUAL LLVM_FIND_VERSION_NODOT) - add_definitions("-DLLVM_${LLVM_VERSION_NODOT}") - endif (LLVM_VERSION_NODOT VERSION_LESS LLVM_FIND_VERSION_NODOT) -endif (LLVM_FIND_VERSION_MAJOR AND LLVM_FIND_VERSION_MINOR) - -if (LLVM_INSTALL_DIR) - find_program(CLANG_EXECUTABLE - NAMES clang-${LLVM_VERSION_NODOT} clang-${LLVM_VERSION_NOPATCH} clang - PATHS ${LLVM_INSTALL_DIR} NO_DEFAULT_PATH) - find_program(LLVM_AS_EXECUTABLE - NAMES llvm-as-${LLVM_VERSION_NODOT} llvm-as-${LLVM_VERSION_NOPATCH} llvm-as - PATHS ${LLVM_INSTALL_DIR} NO_DEFAULT_PATH) - find_program(LLVM_LINK_EXECUTABLE - NAMES llvm-link-${LLVM_VERSION_NODOT} llvm-link-${LLVM_VERSION_NOPATCH} llvm-link - PATHS ${LLVM_INSTALL_DIR} NO_DEFAULT_PATH) -else (LLVM_INSTALL_DIR) - find_program(CLANG_EXECUTABLE - NAMES clang-${LLVM_VERSION_NODOT} clang-${LLVM_VERSION_NOPATCH} clang) - find_program(LLVM_AS_EXECUTABLE - NAMES llvm-as-${LLVM_VERSION_NODOT} llvm-as-${LLVM_VERSION_NOPATCH} llvm-as) - find_program(LLVM_LINK_EXECUTABLE - NAMES llvm-link-${LLVM_VERSION_NODOT} llvm-link-${LLVM_VERSION_NOPATCH} llvm-link) -endif (LLVM_INSTALL_DIR) - -execute_process( - COMMAND ${LLVM_CONFIG_EXECUTABLE} --includedir - OUTPUT_VARIABLE LLVM_INCLUDE_DIR - OUTPUT_STRIP_TRAILING_WHITESPACE -) - -execute_process( - COMMAND ${LLVM_CONFIG_EXECUTABLE} --libdir - OUTPUT_VARIABLE LLVM_LIBRARY_DIR - OUTPUT_STRIP_TRAILING_WHITESPACE -) - -execute_process( - COMMAND ${LLVM_CONFIG_EXECUTABLE} --cppflags - OUTPUT_VARIABLE LLVM_CFLAGS - OUTPUT_STRIP_TRAILING_WHITESPACE -) - -execute_process( - COMMAND ${LLVM_CONFIG_EXECUTABLE} --ldflags - OUTPUT_VARIABLE LLVM_LDFLAGS - OUTPUT_STRIP_TRAILING_WHITESPACE -) - -execute_process( - COMMAND ${LLVM_CONFIG_EXECUTABLE} --libs - OUTPUT_VARIABLE LLVM_MODULE_LIBS - OUTPUT_STRIP_TRAILING_WHITESPACE -) - -if (LLVM_VERSION_NODOT VERSION_GREATER 34) -execute_process( - COMMAND ${LLVM_CONFIG_EXECUTABLE} --system-libs - OUTPUT_VARIABLE LLVM_SYSTEM_LIBS_ORIG - OUTPUT_STRIP_TRAILING_WHITESPACE -) -if (LLVM_SYSTEM_LIBS_ORIG) -string(REGEX REPLACE " *\n" "" LLVM_SYSTEM_LIBS ${LLVM_SYSTEM_LIBS_ORIG}) -endif (LLVM_SYSTEM_LIBS_ORIG) -endif (LLVM_VERSION_NODOT VERSION_GREATER 34) - -macro(add_one_lib name) - FIND_LIBRARY(CLANG_LIB - NAMES ${name} - PATHS ${LLVM_LIBRARY_DIR} NO_DEFAULT_PATH) - set(CLANG_LIBRARIES ${CLANG_LIBRARIES} ${CLANG_LIB}) - unset(CLANG_LIB CACHE) +# Prints a warning/failure message depending on the required/quiet flags. Copied +# from FindPackageHandleStandardArgs.cmake because it doesn't seem to be exposed. +macro(_LLVM_FAIL _msg) + if(LLVM_FIND_REQUIRED) + message(FATAL_ERROR "${_msg}") + else() + if(NOT LLVM_FIND_QUIETLY) + message(STATUS "${_msg}") + endif() + endif() endmacro() -#Assume clang lib path same as llvm lib path -add_one_lib("clangCodeGen") -add_one_lib("clangFrontend") -add_one_lib("clangSerialization") -add_one_lib("clangDriver") -add_one_lib("clangSema") -add_one_lib("clangStaticAnalyzerFrontend") -add_one_lib("clangStaticAnalyzerCheckers") -add_one_lib("clangStaticAnalyzerCore") -add_one_lib("clangAnalysis") -add_one_lib("clangEdit") -add_one_lib("clangAST") -add_one_lib("clangParse") -add_one_lib("clangSema") -add_one_lib("clangLex") -add_one_lib("clangBasic") + +if(NOT LLVM_CONFIG) + if(NOT LLVM_FIND_QUIETLY) + message(WARNING "Could not find llvm-config (LLVM >= ${LLVM_FIND_VERSION}). Try manually setting LLVM_CONFIG to the llvm-config executable of the installation to use.") + endif() +else() + macro(llvm_set var flag) + if(LLVM_FIND_QUIETLY) + set(_quiet_arg ERROR_QUIET) + endif() + set(result_code) + execute_process( + COMMAND ${LLVM_CONFIG} --${flag} + RESULT_VARIABLE result_code + OUTPUT_VARIABLE LLVM_${var} + OUTPUT_STRIP_TRAILING_WHITESPACE + ${_quiet_arg} + ) + if(result_code) + _LLVM_FAIL("Failed to execute llvm-config ('${LLVM_CONFIG}', result code: '${result_code})'") + else() + if(${ARGV2}) + file(TO_CMAKE_PATH "${LLVM_${var}}" LLVM_${var}) + endif() + endif() + endmacro() + macro(llvm_set_libs var flag components) + if(LLVM_FIND_QUIETLY) + set(_quiet_arg ERROR_QUIET) + endif() + set(result_code) + execute_process( + COMMAND ${LLVM_CONFIG} --${flag} ${components} + RESULT_VARIABLE result_code + OUTPUT_VARIABLE tmplibs + OUTPUT_STRIP_TRAILING_WHITESPACE + ${_quiet_arg} + ) + if(result_code) + _LLVM_FAIL("Failed to execute llvm-config ('${LLVM_CONFIG}', result code: '${result_code})'") + else() + file(TO_CMAKE_PATH "${tmplibs}" tmplibs) + string(REGEX MATCHALL "${pattern}[^ ]+" LLVM_${var} ${tmplibs}) + endif() + endmacro() + + llvm_set(VERSION_STRING version) + llvm_set(CXXFLAGS cxxflags) + 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}") + + # 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) + list(REMOVE_ITEM LLVM_FIND_COMPONENTS "demangle" index) + endif() + # Versions below 6.0 do not support component windowsmanifest + if(${LLVM_VERSION_STRING} MATCHES "^[3-5]\\..*") + list(REMOVE_ITEM LLVM_FIND_COMPONENTS "windowsmanifest" index) + endif() + + llvm_set(LDFLAGS ldflags) + # In LLVM 3.5+, the system library dependencies (e.g. "-lz") are accessed + # using the separate "--system-libs" flag. + llvm_set(SYSTEM_LIBS system-libs) + string(REPLACE "\n" " " LLVM_LDFLAGS "${LLVM_LDFLAGS} ${LLVM_SYSTEM_LIBS}") + string(STRIP ${LLVM_LDFLAGS} LLVM_LDFLAGS) + llvm_set(LIBRARY_DIRS libdir true) + llvm_set_libs(LIBRARIES libs "${LLVM_FIND_COMPONENTS}") + # LLVM bug: llvm-config --libs tablegen returns -lLLVM-3.8.0 + # but code for it is not in shared library + if("${LLVM_FIND_COMPONENTS}" MATCHES "tablegen") + if (NOT "${LLVM_LIBRARIES}" MATCHES "LLVMTableGen") + set(LLVM_LIBRARIES "${LLVM_LIBRARIES};-lLLVMTableGen") + endif() + endif() + + # Versions below 4.0 do not support llvm-config --cmakedir + if(${LLVM_VERSION_STRING} MATCHES "^3\\..*") + set(LLVM_CMAKEDIR ${LLVM_LIBRARY_DIRS}/cmake/llvm) + else() + llvm_set(CMAKEDIR cmakedir) + endif() + + llvm_set(TARGETS_TO_BUILD targets-built) + string(REGEX MATCHALL "${pattern}[^ ]+" LLVM_TARGETS_TO_BUILD ${LLVM_TARGETS_TO_BUILD}) + + # Parse LLVM_NATIVE_ARCH manually from LLVMConfig.cmake; including it leads to issues like + # https://github.com/ldc-developers/ldc/issues/3079. + 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() + +# On CMake builds of LLVM, the output of llvm-config --cxxflags does not +# include -fno-rtti, leading to linker errors. Be sure to add it. +if(NOT MSVC AND (CMAKE_COMPILER_IS_GNUCXX OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang"))) + if(NOT ${LLVM_CXXFLAGS} MATCHES "-fno-rtti") + set(LLVM_CXXFLAGS "${LLVM_CXXFLAGS} -fno-rtti") + endif() +endif() + +# Remove some clang-specific flags for gcc. +if(CMAKE_COMPILER_IS_GNUCXX) + string(REPLACE "-Wcovered-switch-default " "" LLVM_CXXFLAGS ${LLVM_CXXFLAGS}) + string(REPLACE "-Wstring-conversion " "" LLVM_CXXFLAGS ${LLVM_CXXFLAGS}) + string(REPLACE "-fcolor-diagnostics " "" LLVM_CXXFLAGS ${LLVM_CXXFLAGS}) + # this requires more recent gcc versions (not supported by 4.9) + string(REPLACE "-Werror=unguarded-availability-new " "" LLVM_CXXFLAGS ${LLVM_CXXFLAGS}) +endif() + +# Remove gcc-specific flags for clang. +if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") + string(REPLACE "-Wno-maybe-uninitialized " "" LLVM_CXXFLAGS ${LLVM_CXXFLAGS}) +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}" ) + +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.") +endif() + +# Use the default CMake facilities for handling QUIET/REQUIRED. +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(LLVM + REQUIRED_VARS LLVM_ROOT_DIR LLVM_HOST_TARGET + VERSION_VAR LLVM_VERSION_STRING) diff --git a/CMakeModules/FindTee.cmake b/CMakeModules/FindTee.cmake new file mode 100644 index 00000000..10c285e1 --- /dev/null +++ b/CMakeModules/FindTee.cmake @@ -0,0 +1,19 @@ + +# FindTee +# -------- +# +# Find tee +# +# This module looks for tee. This module defines the following values: +# +# :: +# +# TEE_EXECUTABLE: the full path to the tee tool. +# TEE_FOUND: True if tee has been found. + +find_program(TEE_EXECUTABLE tee) +mark_as_advanced( TEE_EXECUTABLE ) + +include (FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(TEE REQUIRED_VARS TEE_EXECUTABLE) + diff --git a/include/trick/ABM_Integrator.hh b/include/trick/ABM_Integrator.hh index 8cc96b0b..8489d4d9 100644 --- a/include/trick/ABM_Integrator.hh +++ b/include/trick/ABM_Integrator.hh @@ -14,7 +14,7 @@ Programmers: #ifdef USE_ER7_UTILS_INTEGRATORS #include "er7_utils/integration/abm4/include/abm4_integrator_constructor.hh" -#include "er7_utils/trick/integration/include/first_order_ode_integrator.hh" +#include "er7_utils/trick/integration/include/trick_first_order_ode_integrator.hh" namespace Trick { diff --git a/include/trick/Euler_Cromer_Integrator.hh b/include/trick/Euler_Cromer_Integrator.hh index 27b5ec7a..d62ef831 100644 --- a/include/trick/Euler_Cromer_Integrator.hh +++ b/include/trick/Euler_Cromer_Integrator.hh @@ -16,7 +16,7 @@ Programmers: #include #include "er7_utils/integration/symplectic_euler/include/symplectic_euler_integrator_constructor.hh" -#include "er7_utils/trick/integration/include/second_order_ode_integrator.hh" +#include "er7_utils/trick/integration/include/trick_second_order_ode_integrator.hh" namespace Trick { diff --git a/include/trick/Euler_Integrator.hh b/include/trick/Euler_Integrator.hh index 661e1c1f..50294bb3 100644 --- a/include/trick/Euler_Integrator.hh +++ b/include/trick/Euler_Integrator.hh @@ -14,7 +14,7 @@ Programmers: #ifdef USE_ER7_UTILS_INTEGRATORS #include "er7_utils/integration/euler/include/euler_integrator_constructor.hh" -#include "er7_utils/trick/integration/include/first_order_ode_integrator.hh" +#include "er7_utils/trick/integration/include/trick_first_order_ode_integrator.hh" namespace Trick { diff --git a/include/trick/MM4_Integrator.hh b/include/trick/MM4_Integrator.hh index 1f1a4f38..75972169 100644 --- a/include/trick/MM4_Integrator.hh +++ b/include/trick/MM4_Integrator.hh @@ -14,7 +14,7 @@ Programmers: #ifdef USE_ER7_UTILS_INTEGRATORS #include "er7_utils/integration/mm4/include/mm4_integrator_constructor.hh" -#include "er7_utils/trick/integration/include/second_order_ode_integrator.hh" +#include "er7_utils/trick/integration/include/trick_second_order_ode_integrator.hh" namespace Trick { diff --git a/include/trick/NL2_Integrator.hh b/include/trick/NL2_Integrator.hh index 8dac3513..d391f38d 100644 --- a/include/trick/NL2_Integrator.hh +++ b/include/trick/NL2_Integrator.hh @@ -14,7 +14,7 @@ Programmers: #ifdef USE_ER7_UTILS_INTEGRATORS #include "er7_utils/integration/nl2/include/nl2_integrator_constructor.hh" -#include "er7_utils/trick/integration/include/second_order_ode_integrator.hh" +#include "er7_utils/trick/integration/include/trick_second_order_ode_integrator.hh" namespace Trick { diff --git a/include/trick/RK2_Integrator.hh b/include/trick/RK2_Integrator.hh index 7ef0883a..3aa92453 100644 --- a/include/trick/RK2_Integrator.hh +++ b/include/trick/RK2_Integrator.hh @@ -14,7 +14,7 @@ Programmers: #ifdef USE_ER7_UTILS_INTEGRATORS #include "er7_utils/integration/rk2_heun/include/rk2_heun_integrator_constructor.hh" -#include "er7_utils/trick/integration/include/first_order_ode_integrator.hh" +#include "er7_utils/trick/integration/include/trick_first_order_ode_integrator.hh" namespace Trick { diff --git a/include/trick/RK4_Integrator.hh b/include/trick/RK4_Integrator.hh index 108a5701..cd1a36ab 100644 --- a/include/trick/RK4_Integrator.hh +++ b/include/trick/RK4_Integrator.hh @@ -14,7 +14,7 @@ Programmers: #ifdef USE_ER7_UTILS_INTEGRATORS #include "er7_utils/integration/rk4/include/rk4_integrator_constructor.hh" -#include "er7_utils/trick/integration/include/first_order_ode_integrator.hh" +#include "er7_utils/trick/integration/include/trick_first_order_ode_integrator.hh" namespace Trick { diff --git a/include/trick/RKF45_Integrator.hh b/include/trick/RKF45_Integrator.hh index 385d81d4..dd4cca64 100644 --- a/include/trick/RKF45_Integrator.hh +++ b/include/trick/RKF45_Integrator.hh @@ -14,7 +14,7 @@ Programmers: #ifdef USE_ER7_UTILS_INTEGRATORS #include "er7_utils/integration/rkf45/include/rkf45_integrator_constructor.hh" -#include "er7_utils/trick/integration/include/first_order_ode_integrator.hh" +#include "er7_utils/trick/integration/include/trick_first_order_ode_integrator.hh" namespace Trick { diff --git a/include/trick/RKF78_Integrator.hh b/include/trick/RKF78_Integrator.hh index 4806d7b9..afbf8a43 100644 --- a/include/trick/RKF78_Integrator.hh +++ b/include/trick/RKF78_Integrator.hh @@ -14,7 +14,7 @@ Programmers: #ifdef USE_ER7_UTILS_INTEGRATORS #include "er7_utils/integration/rkf78/include/rkf78_integrator_constructor.hh" -#include "er7_utils/trick/integration/include/first_order_ode_integrator.hh" +#include "er7_utils/trick/integration/include/trick_first_order_ode_integrator.hh" namespace Trick { diff --git a/include/trick/RKG4_Integrator.hh b/include/trick/RKG4_Integrator.hh index d19c877a..007e212f 100644 --- a/include/trick/RKG4_Integrator.hh +++ b/include/trick/RKG4_Integrator.hh @@ -14,7 +14,7 @@ Programmers: #ifdef USE_ER7_UTILS_INTEGRATORS #include "er7_utils/integration/rkg4/include/rkg4_integrator_constructor.hh" -#include "er7_utils/trick/integration/include/first_order_ode_integrator.hh" +#include "er7_utils/trick/integration/include/trick_first_order_ode_integrator.hh" namespace Trick { diff --git a/share/trick/makefiles/config_user.mk.in b/share/trick/makefiles/config_user.mk.in index 657f05f2..23f12bff 100644 --- a/share/trick/makefiles/config_user.mk.in +++ b/share/trick/makefiles/config_user.mk.in @@ -1,16 +1,16 @@ TRICK_FORCE_32BIT = @TRICK_FORCE_32BIT@ -CC = @CC@ -CXX = @CXX@ -LD = @LD@ -PERL = @PERL@ -LEX = @LEX@ -YACC = @BISON@ -SWIG = @SWIG@ -PYTHON = @PYTHON@ -CLANG = @CLANG@ -TEE = @TEE@ +CC = @CMAKE_C_COMPILER@ +CXX = @CMAKE_CXX_COMPILER@ +LD = @CMAKE_LINKER@ +PERL = @PERL_EXECUTABLE@ +LEX = @FLEX_EXECUTABLE@ +YACC = @BISON_EXECUTABLE@ +SWIG = @SWIG_EXECUTABLE@ +PYTHON = @PYTHON_EXECUTABLE@ +CLANG = @CLANG_EXECUTABLE@ +TEE = @TEE_EXECUTABLE@ USE_JAVA = @USE_JAVA@ JAVAC = @JAVA_CC@ diff --git a/trick_source/er7_utils/trick/include/files_to_ICG.hh b/trick_source/er7_utils/trick/include/files_to_ICG.hh index 5f491340..379a5a6a 100644 --- a/trick_source/er7_utils/trick/include/files_to_ICG.hh +++ b/trick_source/er7_utils/trick/include/files_to_ICG.hh @@ -9,7 +9,7 @@ #include "er7_utils/math/include/n_choose_m.hh" #include "er7_utils/math/include/ratio128.hh" #include "er7_utils/math/include/uint128.hh" -#include "er7_utils/trick/integration/include/first_order_ode_integrator.hh" -#include "er7_utils/trick/integration/include/second_order_ode_integrator.hh" +#include "er7_utils/trick/integration/include/trick_first_order_ode_integrator.hh" +#include "er7_utils/trick/integration/include/trick_second_order_ode_integrator.hh" #endif diff --git a/trick_source/er7_utils/trick/integration/include/first_order_ode_integrator.hh b/trick_source/er7_utils/trick/integration/include/trick_first_order_ode_integrator.hh similarity index 100% rename from trick_source/er7_utils/trick/integration/include/first_order_ode_integrator.hh rename to trick_source/er7_utils/trick/integration/include/trick_first_order_ode_integrator.hh diff --git a/trick_source/er7_utils/trick/integration/include/second_order_ode_integrator.hh b/trick_source/er7_utils/trick/integration/include/trick_second_order_ode_integrator.hh similarity index 100% rename from trick_source/er7_utils/trick/integration/include/second_order_ode_integrator.hh rename to trick_source/er7_utils/trick/integration/include/trick_second_order_ode_integrator.hh diff --git a/trick_source/trick_swig/sim_services.i b/trick_source/trick_swig/sim_services.i index 1984d64d..c2ea71d8 100644 --- a/trick_source/trick_swig/sim_services.i +++ b/trick_source/trick_swig/sim_services.i @@ -150,8 +150,8 @@ #include "er7_utils/integration/core/include/integrator_constructor_factory.hh" #include "er7_utils/integration/core/include/integrable_object.hh" #include "er7_utils/integration/core/include/base_integration_group.hh" -#include "er7_utils/trick/integration/include/first_order_ode_integrator.hh" -#include "er7_utils/trick/integration/include/second_order_ode_integrator.hh" +#include "er7_utils/trick/integration/include/trick_first_order_ode_integrator.hh" +#include "er7_utils/trick/integration/include/trick_second_order_ode_integrator.hh" #endif %}