Integrate libiomp CMake into LLVM CMake build system.

This patch integrates the libiomp CMake build system into the LLVM CMake build 
system so that users can checkout libiomp into the projects directory of llvm 
and build llvm,clang, and libiomp all together.  These changes specifically 
introduce a new install target which will put libraries and headers into the 
correct locations when either a standalone build or part of llvm.
The copy_recipe() method has been removed in favor of the POST_BUILD method 
to move headers into the exports subdirectory.  And lastly, the MicroTests.cmake 
file was refactored which led to simpler target dependencies and a new target, 
make libiomp-micro-tests, which performs the 5 small tests (test-relo, 
test-touch, etc.) when called.

llvm-svn: 236534
This commit is contained in:
Andrey Churbanov 2015-05-05 20:02:52 +00:00
parent 22f6189fb0
commit 648467ed05
6 changed files with 342 additions and 356 deletions

2
openmp/CMakeLists.txt Normal file
View File

@ -0,0 +1,2 @@
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
add_subdirectory(runtime)

View File

@ -12,7 +12,6 @@
################
# CMAKE libiomp5
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(libiomp C CXX)
#########
# GLOBALS
@ -25,6 +24,15 @@ set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
# The top-level CMakeLists.txt should define this variable.
set(LIBOMP_WORK ${CMAKE_CURRENT_SOURCE_DIR})
#######################################################################
# Standalone build or part of LLVM?
set(LIBIOMP_STANDALONE_BUILD FALSE)
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}" OR
"${CMAKE_SOURCE_DIR}/runtime" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
project(libiomp C CXX)
set(LIBIOMP_STANDALONE_BUILD TRUE)
endif()
# These include files are in cmake/ subdirectory except for FindPerl which is a cmake standard module
include(HelperFunctions)
include(Definitions) # -D definitions when compiling
@ -102,13 +110,13 @@ set(ompt_blame true CACHE BOOL "OMPT-blame?"
set(ompt_trace true CACHE BOOL "OMPT-trace?" )
# User specified flags. These are appended to the predetermined flags found in CommonFlags.cmake and ${CMAKE_C_COMPILER_ID}/*Flags.cmake (e.g., GNU/CFlags.cmake)
set(USER_C_FLAGS "" CACHE STRING "Appended user specified C compiler flags." )
set(USER_CXX_FLAGS "" CACHE STRING "Appended user specified C++ compiler flags." )
set(USER_CPP_FLAGS "" CACHE STRING "Appended user specified C preprocessor flags." )
set(USER_ASM_FLAGS "" CACHE STRING "Appended user specified assembler flags." )
set(USER_LD_FLAGS "" CACHE STRING "Appended user specified linker flags." )
set(USER_LD_LIB_FLAGS "" CACHE STRING "Appended user specified linked libs flags. (e.g., -lm)")
set(USER_F_FLAGS "" CACHE STRING "Appended user specified Fortran compiler flags. These are only used if create_fortran_modules==true." )
set(LIBIOMP_CFLAGS "" CACHE STRING "Appended user specified C compiler flags." )
set(LIBIOMP_CXXFLAGS "" CACHE STRING "Appended user specified C++ compiler flags." )
set(LIBIOMP_CPPFLAGS "" CACHE STRING "Appended user specified C preprocessor flags." )
set(LIBIOMP_ASMFLAGS "" CACHE STRING "Appended user specified assembler flags." )
set(LIBIOMP_LDFLAGS "" CACHE STRING "Appended user specified linker flags." )
set(LIBIOMP_LIBFLAGS "" CACHE STRING "Appended user specified linked libs flags. (e.g., -lm)")
set(LIBIOMP_FFLAGS "" CACHE STRING "Appended user specified Fortran compiler flags. These are only used if create_fortran_modules==true." )
# - Allow three build types: Release, Debug, RelWithDebInfo (these relate to build.pl's release, debug, and diag settings respectively)
# - default is Release (when CMAKE_BUILD_TYPE is not defined)
@ -128,6 +136,12 @@ else()
check_variable(cmake_build_type_lowercase "${build_type_possible_values}")
endif()
if(${LIBIOMP_STANDALONE_BUILD})
set(LIBIOMP_LIBDIR_SUFFIX "" CACHE STRING "suffix of lib installation directory e.g., 64 => lib64")
else()
set(LIBIOMP_LIBDIR_SUFFIX ${LLVM_LIBDIR_SUFFIX})
endif()
# Check valid values
check_variable(os "${os_possible_values}" )
check_variable(arch "${arch_possible_values}" )
@ -339,8 +353,11 @@ set(build_dir "${CMAKE_CURRENT_BINARY_DIR}" ) # build directory (Wher
set(src_dir "${LIBOMP_WORK}/src" )
set(tools_dir "${LIBOMP_WORK}/tools" )
set(export_dir "${LIBOMP_WORK}/exports" )
set(export_cmn_dir "${export_dir}/common${suffix}" )
set(export_ptf_dir "${export_dir}/${platform}${suffix}")
set(export_cmn_dir1 "${export_dir}/common${suffix}/include")
set(export_cmn_dir2 "${export_dir}/common${suffix}/include_compat")
set(export_inc_dir "${export_ptf_dir}/include")
set(export_mod_dir "${export_ptf_dir}/include_compat")
_export_lib_dir(${platform} export_lib_dir) # set exports directory (relative to build_dir) e.g., ../exports/lin_32e/lib/
# or ../exports/mac_32e/lib.thin/ for mac
if(${MAC})
@ -371,7 +388,7 @@ set(lib_ext "${dll}")
set(lib_file "${lib_item}${lib_ext}")
########################################
# Setting export file names (full paths)
# Setting export file names
if(${WINDOWS})
set(imp_file "${lib_item}${lib}") # this is exported (libiomp5md.lib)
set(def_file "${lib_item}.def") # this is not exported
@ -390,15 +407,9 @@ if(${OMPT_SUPPORT})
set(export_cmn_files1 ${export_cmn_files1} "ompt.h")
endif()
add_prefix("${export_lib_dir}/" export_lib_files)
add_prefix("${export_ptf_dir}/include_compat/" export_inc_files)
add_prefix("${export_ptf_dir}/include/" export_mod_files)
add_prefix("${export_cmn_dir}/include/" export_cmn_files1)
add_prefix("${export_cmn_dir}/include_compat/" export_cmn_files2)
set(export_cmn_files "${export_cmn_files1}" "${export_cmn_files2}")
if("${export_lib_fat_dir}")
set(export_lib_fat_files "${lib_file}" "${imp_file}")
add_prefix("${export_lib_fat_dir}/" export_lib_fat_files)
endif()
#########################
@ -415,7 +426,7 @@ set_legal_arch(legal_arch)
# Linker Flags (cmake/CommonFlags.cmake)
# Archiver Flags (cmake/CommonFlags.cmake)
# Helper Perl Script Flags (cmake/PerlFlags.cmake)
# * Inside the cmake/CommonFlags.cmake file, the USER_*_FLAGS are added.
# * Inside the cmake/CommonFlags.cmake file, the LIBIOMP_*FLAGS are added.
# * Cannot use CMAKE_*_FLAGS directly because -x c++ is put in the linker command and mangles the linking phase.
# preprocessor flags (-D definitions and -I includes)
@ -423,6 +434,17 @@ set_legal_arch(legal_arch)
set(include_dirs ${CMAKE_CURRENT_BINARY_DIR} ${src_dir} ${src_dir}/i18n ${inc_dir} ${src_dir}/thirdparty/ittnotify)
include_directories(${include_dirs})
# Grab compiler-dependent flags
# Cmake will look for cmake/${CMAKE_C_COMPILER_ID}/CFlags.cmake to append additional c, cxx, and linker flags.
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${CMAKE_C_COMPILER_ID} ${CMAKE_MODULE_PATH})
find_file(compiler_specific_include_file_found CFlags.cmake ${CMAKE_MODULE_PATH})
if(compiler_specific_include_file_found)
include(CFlags) # COMPILER_SUPPORTS_QUAD_PRECISION changed in here
append_compiler_specific_c_and_cxx_flags(C_FLAGS CXX_FLAGS)
append_compiler_specific_linker_flags(LD_FLAGS LD_LIB_FLAGS)
else()
warning_say("Could not find cmake/${CMAKE_C_COMPILER_ID}/CFlags.cmake: will only use default flags")
endif()
# Grab assembler-dependent flags
# CMake will look for cmake/${CMAKE_ASM_COMPILER_ID}/AsmFlags.cmake to append additional assembler flags.
if(${WINDOWS})
@ -440,8 +462,6 @@ if(${WINDOWS})
else()
# Unix (including Mac) based systems use CMAKE_ASM_COMPILER
# Unix assembly files can be handled by compiler usually.
enable_language(ASM)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${CMAKE_ASM_COMPILER_ID} ${CMAKE_MODULE_PATH})
find_file(assembler_specific_include_file_found AsmFlags.cmake ${CMAKE_MODULE_PATH})
if(assembler_specific_include_file_found)
include(AsmFlags)
@ -450,17 +470,6 @@ else()
warning_say("Could not find cmake/${CMAKE_ASM_COMPILER_ID}/AsmFlags.cmake: will only use default flags")
endif()
endif()
# Grab compiler-dependent flags
# Cmake will look for cmake/${CMAKE_C_COMPILER_ID}/CFlags.cmake to append additional c, cxx, and linker flags.
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${CMAKE_C_COMPILER_ID} ${CMAKE_MODULE_PATH})
find_file(compiler_specific_include_file_found CFlags.cmake ${CMAKE_MODULE_PATH})
if(compiler_specific_include_file_found)
include(CFlags) # COMPILER_SUPPORTS_QUAD_PRECISION changed in here
append_compiler_specific_c_and_cxx_flags(C_FLAGS CXX_FLAGS)
append_compiler_specific_linker_flags(LD_FLAGS LD_LIB_FLAGS)
else()
warning_say("Could not find cmake/${CMAKE_C_COMPILER_ID}/CFlags.cmake: will only use default flags")
endif()
# Grab all the compiler-independent flags
append_c_and_cxx_flags_common(C_FLAGS CXX_FLAGS)
@ -552,62 +561,44 @@ debug_say_var(imp_src_files)
####################
# --- Create all ---
add_custom_target(lib ALL DEPENDS ${export_lib_files})
add_custom_target(lib ALL DEPENDS iomp5)
add_custom_target(inc ALL DEPENDS ${export_inc_files})
if(${create_fortran_modules})
add_custom_target(mod ALL DEPENDS ${export_mod_files})
endif()
# --- Enforce the tests to be completed/skipped before copying to exports directory ---
if(${tests})
if(${WINDOWS})
set(test-dependencies test-touch-mt/.success test-touch-md/.success test-relo/.success test-execstack/.success test-instr/.success test-deps/.success)
else()
set(test-dependencies test-touch-rt/.success test-relo/.success test-execstack/.success test-instr/.success test-deps/.success)
endif()
set_source_files_properties(${export_lib_files} PROPERTIES OBJECT_DEPENDS "${test-dependencies}")
endif()
#############################
# --- Create Common Files ---
add_custom_target(common ALL DEPENDS ${export_cmn_files})
add_custom_target(clean-common COMMAND ${CMAKE_COMMAND} -E remove -f ${export_cmn_files})
##########################################
# --- Copy files to export directories ---
# - just a simple copy recipe which acts as an install step
# - copies out of the src_dir into the dest_dir
#
# dest_dir/target : src_dir/target
# cp src_dir/target dest_dir/target
macro (simple_copy_recipe target src_dir dest_dir)
get_source_file_property(extra_depends ${dest_dir}/${target} OBJECT_DEPENDS)
if("${extra_depends}" MATCHES "NOTFOUND")
set(extra_depends)
endif()
set(ldeps ${src_dir}/${target} "${extra_depends}")
if(NOT "${target}" STREQUAL "")
file(MAKE_DIRECTORY ${dest_dir}) # make sure destination directory exists
add_custom_command(
OUTPUT ${dest_dir}/${target}
COMMAND ${CMAKE_COMMAND} -E copy ${src_dir}/${target} ${dest_dir}/${target}
DEPENDS ${ldeps}
# --- Put headers in convenient locations post build ---
add_custom_command(TARGET common POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${export_cmn_dir1}
COMMAND ${CMAKE_COMMAND} -E make_directory ${export_cmn_dir2}
COMMAND ${CMAKE_COMMAND} -E copy omp.h ${export_cmn_dir1}
COMMAND ${CMAKE_COMMAND} -E copy omp_lib.h ${export_cmn_dir1}
COMMAND ${CMAKE_COMMAND} -E copy omp_lib.f ${export_cmn_dir1}
COMMAND ${CMAKE_COMMAND} -E copy omp_lib.f90 ${export_cmn_dir1}
COMMAND ${CMAKE_COMMAND} -E copy iomp.h ${export_cmn_dir2}
)
if(${OMPT_SUPPORT})
add_custom_command(TARGET common POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${export_cmn_dir1}
COMMAND ${CMAKE_COMMAND} -E copy ompt.h ${export_cmn_dir1}
)
endif()
add_custom_command(TARGET inc POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${export_inc_dir}
COMMAND ${CMAKE_COMMAND} -E copy iomp_lib.h ${export_inc_dir}
)
if(${create_fortran_modules})
add_custom_command(TARGET mod POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${export_mod_dir}
COMMAND ${CMAKE_COMMAND} -E copy omp_lib.mod ${export_mod_dir}
COMMAND ${CMAKE_COMMAND} -E copy omp_lib_kinds.mod ${export_mod_dir}
)
endif()
endmacro()
# copy from build directory to final resting places in exports directory
simple_copy_recipe("omp.h" "${build_dir}" "${export_cmn_dir}/include")
simple_copy_recipe("ompt.h" "${build_dir}" "${export_cmn_dir}/include")
simple_copy_recipe("omp_lib.h" "${build_dir}" "${export_cmn_dir}/include")
simple_copy_recipe("omp_lib.f" "${build_dir}" "${export_cmn_dir}/include")
simple_copy_recipe("omp_lib.f90" "${build_dir}" "${export_cmn_dir}/include")
simple_copy_recipe("iomp.h" "${build_dir}" "${export_cmn_dir}/include_compat")
simple_copy_recipe("${lib_file}" "${build_dir}" "${export_lib_dir}")
simple_copy_recipe("${imp_file}" "${build_dir}" "${export_lib_dir}")
simple_copy_recipe("${pdb_file}" "${build_dir}" "${export_lib_dir}")
simple_copy_recipe("${dbg_file}" "${build_dir}" "${export_lib_dir}")
simple_copy_recipe("omp_lib.mod" "${build_dir}" "${export_ptf_dir}/include")
simple_copy_recipe("omp_lib_kinds.mod" "${build_dir}" "${export_ptf_dir}/include")
simple_copy_recipe("iomp_lib.h" "${build_dir}" "${export_ptf_dir}/include_compat")
######################################################
# --- Build the main library ---
@ -621,11 +612,6 @@ add_custom_target(needed-headers DEPENDS ${build_dir}/kmp_i18n_id.inc ${build_di
if(${WINDOWS})
add_custom_target(needed-windows-files DEPENDS ${build_dir}/${def_file} ${build_dir}/${rc_file})
list(APPEND lib_src_files ${build_dir}/${rc_file})
# The windows assembly files are in MASM format, and they require a tool that can handle MASM syntax (ml.exe or ml64.exe typically)
enable_language(ASM_MASM)
else()
# Unix assembly files can be handled by compiler.
enable_language(ASM)
endif()
# Remove any cmake-automatic linking of libraries by linker, This is so linux
@ -645,8 +631,21 @@ set_target_properties(iomp5 PROPERTIES
LINKER_LANGUAGE C # use C Compiler for linking step
SKIP_BUILD_RPATH true # have Mac linker -install_name just be "-install_name libiomp5.dylib"
)
# Target lib (export files) depend on the library (iomp5) being built
add_dependencies(lib iomp5)
# --- Copy libiomp into exports directory post build ---
if(${WINDOWS})
get_target_property(LIBIOMP_OUTPUT_DIRECTORY iomp5 RUNTIME_OUTPUT_DIRECTORY)
else()
get_target_property(LIBIOMP_OUTPUT_DIRECTORY iomp5 LIBRARY_OUTPUT_DIRECTORY)
endif()
if(NOT LIBIOMP_OUTPUT_DIRECTORY)
set(LIBIOMP_OUTPUT_DIRECTORY ${build_dir})
endif()
add_custom_command(TARGET iomp5 POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${export_lib_dir}
COMMAND ${CMAKE_COMMAND} -E copy ${LIBIOMP_OUTPUT_DIRECTORY}/${lib_file} ${export_lib_dir}
)
# Linking command will include libraries in LD_LIB_FLAGS
target_link_libraries(iomp5 ${LD_LIB_FLAGS} ${CMAKE_DL_LIBS})
@ -662,7 +661,13 @@ endif()
set_source_files_properties(${lib_c_items}
${imp_c_items} PROPERTIES COMPILE_FLAGS "${C_FLAGS}" )
set_source_files_properties(${lib_cxx_items} PROPERTIES COMPILE_FLAGS "${CXX_FLAGS}")
if(${WINDOWS})
# Windows operating system has to use MASM assembler
set_source_files_properties(${lib_asm_items} PROPERTIES COMPILE_FLAGS "${ASM_FLAGS}")
else()
# Non-Windows operating systems can use compiler to assemble the assembly files
set_source_files_properties(${lib_asm_items} PROPERTIES COMPILE_FLAGS "${ASM_FLAGS}" LANGUAGE C)
endif()
# Set the -D definitions for all sources
add_definitions(${DEFINITIONS_FLAGS})
@ -701,10 +706,10 @@ if(${MAC})
_export_lib_fat_dir( "mac_32e" export_fat_mac_32e)
_export_lib_dir( "mac_32" export_mac_32 )
_export_lib_dir( "mac_32e" export_mac_32e )
file(MAKE_DIRECTORY ${export_fat_mac_32e})
add_custom_target(fat
COMMAND ${CMAKE_COMMAND} -E echo Building 32 and 32e fat libraries from ${export_mac_32}/${lib_file} and ${export_mac_32e}/${lib_file}
COMMAND ${CMAKE_COMMAND} -E echo Will put fat library in ${export_fat_mac_32e} directory
COMMAND ${CMAKE_COMMAND} -E make_directory ${export_fat_mac_32e}
COMMAND lipo -create -output ${export_fat_mac_32e}/${lib_file} ${export_mac_32}/${lib_file} ${export_mac_32e}/${lib_file}
)
endif()
@ -730,6 +735,14 @@ if(${WINDOWS})
)
add_custom_command(TARGET iomp5imp PRE_BUILD COMMAND ${CMAKE_COMMAND} -E remove -f ${imp_file})
add_dependencies(iomp5imp iomp5)
get_target_property(LIBIOMPIMP_OUTPUT_DIRECTORY iomp5imp ARCHIVE_OUTPUT_DIRECTORY)
if(NOT LIBIOMPIMP_OUTPUT_DIRECTORY)
set(LIBIOMPIMP_OUTPUT_DIRECTORY ${build_dir})
endif()
add_custom_command(TARGET iomp5imp POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${export_lib_dir}
COMMAND ${CMAKE_COMMAND} -E copy ${LIBIOMPIMP_OUTPUT_DIRECTORY}/${imp_file} ${export_lib_dir}
)
endif()
# --- Create $(def_file) ---
@ -772,6 +785,22 @@ add_custom_command(
# - Only perform if ${tests} == true (specify when invoking: cmake -Dtests=on ...)
if(${tests})
include(MicroTests)
add_custom_target(libiomp-micro-tests)
if(NOT ${MIC} AND ${test_touch})
add_dependencies(libiomp-micro-tests libiomp-test-touch)
endif()
if(${LINUX} AND ${test_relo})
add_dependencies(libiomp-micro-tests libiomp-test-relo)
endif()
if(${LINUX} AND ${test_execstack})
add_dependencies(libiomp-micro-tests libiomp-test-execstack)
endif()
if(${MIC} AND ${test_instr})
add_dependencies(libiomp-micro-tests libiomp-test-instr)
endif()
if(${test_deps})
add_dependencies(libiomp-micro-tests libiomp-test-deps)
endif()
endif()
######################################################
@ -808,21 +837,18 @@ endif()
# --- Using expand-vars.pl to generate files ---
# - 'file' is generated using expand-vars.pl and 'file'.var
# - Any .h .f .f90 .rc files should be created with this recipe
macro(expand_vars_recipe filename)
macro(expand_vars_recipe file_dir filename)
get_source_file_property(extra_ev_flags ${filename} COMPILE_DEFINITIONS)
if("${extra_ev_flags}" MATCHES "NOTFOUND")
set(extra_ev_flags)
else()
string_to_list("${extra_ev_flags}" extra_ev_flags)
endif()
find_file(${filename}_path ${filename}.var PATHS ${src_dir}/include/${omp_version} ${src_dir})
set(ldeps "${${filename}_path}" "${src_dir}/kmp_version.c" "${tools_dir}/expand-vars.pl")
set(expandvarscmd ${PERL_EXECUTABLE} ${tools_dir}/expand-vars.pl --strict ${ev_flags} ${extra_ev_flags} ${${filename}_path} ${filename})
if(NOT "${filename}" STREQUAL "")
add_custom_command(
OUTPUT ${filename}
COMMAND ${expandvarscmd}
DEPENDS ${ldeps}
COMMAND ${PERL_EXECUTABLE} ${tools_dir}/expand-vars.pl --strict ${ev_flags} ${extra_ev_flags} ${file_dir}/${filename}.var ${filename}
DEPENDS ${file_dir}/${filename}.var ${src_dir}/kmp_version.c ${tools_dir}/expand-vars.pl
)
endif()
endmacro()
@ -837,46 +863,71 @@ else()
endif()
# libiomp.rc : ev-flags += -D KMP_FILE=$(lib_file)
set_source_files_properties(libiomp.rc PROPERTIES COMPILE_DEFINITIONS "-D KMP_FILE=${lib_file}")
expand_vars_recipe(omp.h)
expand_vars_recipe(ompt.h)
expand_vars_recipe(omp_lib.h)
expand_vars_recipe(omp_lib.f)
expand_vars_recipe(omp_lib.f90)
expand_vars_recipe(iomp.h)
expand_vars_recipe(iomp_lib.h)
expand_vars_recipe(libiomp.rc)
expand_vars_recipe(${src_dir}/include/${omp_version} omp.h)
expand_vars_recipe(${src_dir}/include/${omp_version} ompt.h)
expand_vars_recipe(${src_dir}/include/${omp_version} omp_lib.h)
expand_vars_recipe(${src_dir}/include/${omp_version} omp_lib.f)
expand_vars_recipe(${src_dir}/include/${omp_version} omp_lib.f90)
expand_vars_recipe(${src_dir}/include/${omp_version} iomp.h)
expand_vars_recipe(${src_dir}/include/${omp_version} iomp_lib.h)
expand_vars_recipe(${src_dir} libiomp.rc)
####################################################################
# Print configuration after all variables are set.
say("")
say("----------------------- CONFIGURATION -----------------------")
say("Operating System : ${os}")
say("Target Architecture : ${arch}")
if(${LIBIOMP_STANDALONE_BUILD})
say("LIBIOMP: Operating System -- ${os}")
say("LIBIOMP: Target Architecture -- ${arch}")
if(${MIC})
say("Intel(R) MIC Architecture : ${mic_arch}")
say("LIBIOMP: Intel(R) MIC Architecture -- ${mic_arch}")
endif()
say("Build Type : ${CMAKE_BUILD_TYPE}")
say("OpenMP Version : ${omp_version}")
say("Lib Type : ${lib_type}")
say("Fortran Modules : ${create_fortran_modules}")
say("LIBIOMP: Build Type -- ${CMAKE_BUILD_TYPE}")
say("LIBIOMP: OpenMP Version -- ${omp_version}")
say("LIBIOMP: Lib Type -- ${lib_type}")
say("LIBIOMP: Fortran Modules -- ${create_fortran_modules}")
# will say development if all zeros
if("${build_number}" STREQUAL "00000000")
set(build "development")
else()
set(build "${build_number}")
endif()
say("Build : ${build}")
say("Stats-Gathering : ${stats}")
say("OMPT-support : ${ompt_support}")
say("LIBIOMP: Build -- ${build}")
say("LIBIOMP: Stats-Gathering -- ${stats}")
say("LIBIOMP: OMPT-support -- ${ompt_support}")
if(${OMPT_SUPPORT})
say("OMPT-blame : ${ompt_blame}")
say("OMPT-trace : ${ompt_trace}")
say("LIBIOMP: OMPT-blame -- ${ompt_blame}")
say("LIBIOMP: OMPT-trace -- ${ompt_trace}")
endif()
say("LIBIOMP: Use build.pl rules -- ${USE_BUILDPL_RULES}")
say("LIBIOMP: Adaptive locks -- ${USE_ADAPTIVE_LOCKS}")
say("LIBIOMP: Use predefined linker flags -- ${USE_PREDEFINED_LINKER_FLAGS}")
say("LIBIOMP: Compiler supports quad precision -- ${COMPILER_SUPPORTS_QUAD_PRECISION}")
endif()
####################################################################
# Install rules
# We want to install libiomp5 in DESTDIR/CMAKE_INSTALL_PREFIX/lib
# We want to install headers in DESTDIR/CMAKE_INSTALL_PREFIX/include
if(${LIBIOMP_STANDALONE_BUILD})
set(LIBIOMP_HEADERS_INSTALL_PATH include)
else()
string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION ${PACKAGE_VERSION})
set(LIBIOMP_HEADERS_INSTALL_PATH lib${LIBIOMP_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include)
endif()
if(${WINDOWS})
install(TARGETS iomp5 RUNTIME DESTINATION bin)
if(NOT "${imp_file}" STREQUAL "")
install(TARGETS iomp5imp ARCHIVE DESTINATION lib${LIBIOMP_LIBDIR_SUFFIX})
endif()
else()
install(TARGETS iomp5 LIBRARY DESTINATION lib${LIBIOMP_LIBDIR_SUFFIX})
endif()
install(
FILES
${build_dir}/omp.h
${build_dir}/iomp.h
DESTINATION ${LIBIOMP_HEADERS_INSTALL_PATH}
)
if(${OMPT_SUPPORT})
install( FILES ${build_dir}/ompt.h DESTINATION ${LIBIOMP_HEADERS_INSTALL_PATH})
endif()
say("Use build.pl rules : ${USE_BUILDPL_RULES}")
say("Adaptive locks : ${USE_ADAPTIVE_LOCKS}")
say("Use predefined linker flags : ${USE_PREDEFINED_LINKER_FLAGS}")
say("Compiler supports quad precision : ${COMPILER_SUPPORTS_QUAD_PRECISION}")
say("-------------------------------------------------------------")
say("")

View File

@ -57,7 +57,7 @@ endmacro()
# Global Assembly flags
function(append_asm_flags_common input_asm_flags)
set(local_asm_flags)
set(${input_asm_flags} "${${input_asm_flags}}" "${local_asm_flags}" "${USER_ASM_FLAGS}" PARENT_SCOPE)
set(${input_asm_flags} "${${input_asm_flags}}" "${local_asm_flags}" "${LIBIOMP_ASMFLAGS}" PARENT_SCOPE)
endfunction()
#########################################################
@ -65,15 +65,15 @@ endfunction()
function(append_c_and_cxx_flags_common input_c_flags input_cxx_flags)
set(local_c_flags)
set(local_cxx_flags)
set(${input_c_flags} "${${input_c_flags}}" "${local_c_flags}" "${USER_C_FLAGS}" PARENT_SCOPE)
set(${input_cxx_flags} "${${input_cxx_flags}}" "${local_cxx_flags}" "${USER_CXX_FLAGS}" PARENT_SCOPE)
set(${input_c_flags} "${${input_c_flags}}" "${local_c_flags}" "${LIBIOMP_CFLAGS}" PARENT_SCOPE)
set(${input_cxx_flags} "${${input_cxx_flags}}" "${local_cxx_flags}" "${LIBIOMP_CXXFLAGS}" PARENT_SCOPE)
endfunction()
#########################################################
# Global Fortran Compiler flags (for creating .mod files)
function(append_fort_flags_common input_fort_flags)
set(local_fort_flags)
set(${input_fort_flags} "${${input_fort_flags}}" "${local_fort_flags}" "${USER_F_FLAGS}" PARENT_SCOPE)
set(${input_fort_flags} "${${input_fort_flags}}" "${local_fort_flags}" "${LIBIOMP_FFLAGS}" PARENT_SCOPE)
endfunction()
#########################################################
@ -125,8 +125,8 @@ function(append_linker_flags_common input_ld_flags input_ld_flags_libs)
endif() # USE_PREDEFINED_LINKER_FLAGS
set(${input_ld_flags} "${${input_ld_flags}}" "${local_ld_flags}" "${USER_LD_FLAGS}" PARENT_SCOPE)
set(${input_ld_flags_libs} "${${input_ld_flags_libs}}" "${local_ld_flags_libs}" "${USER_LD_LIB_FLAGS}" PARENT_SCOPE)
set(${input_ld_flags} "${${input_ld_flags}}" "${local_ld_flags}" "${LIBIOMP_LDFLAGS}" PARENT_SCOPE)
set(${input_ld_flags_libs} "${${input_ld_flags_libs}}" "${local_ld_flags_libs}" "${LIBIOMP_LIBFLAGS}" PARENT_SCOPE)
endfunction()
#########################################################

View File

@ -155,6 +155,6 @@ function(append_cpp_flags input_cpp_flags)
else()
append_definitions("-D KMP_USE_INTERNODE_ALIGNMENT=0")
endif()
set(${input_cpp_flags} "${${input_cpp_flags}}" "${local_cpp_flags}" "${USER_CPP_FLAGS}" "$ENV{CPPFLAGS}" PARENT_SCOPE)
set(${input_cpp_flags} "${${input_cpp_flags}}" "${local_cpp_flags}" "${LIBIOMP_CPPFLAGS}" "$ENV{CPPFLAGS}" PARENT_SCOPE)
endfunction()

View File

@ -22,7 +22,7 @@
# void say(string message_to_user);
# - prints out message_to_user
macro(say message_to_user)
message("${message_to_user}")
message(STATUS "${message_to_user}")
endmacro()
# void warning_say(string message_to_user);

View File

@ -44,7 +44,6 @@
# An individual test can be turned off by issuing something like -Dtest_touch=off when calling cmake
# test-touch
if(NOT ${MIC} AND ${test_touch} AND ${tests})
if(${WINDOWS})
set(do_test_touch_mt TRUE)
if(${do_test_touch_mt})
@ -59,7 +58,7 @@ if(NOT ${MIC} AND ${test_touch} AND ${tests})
add_suffix("/.success" regular_test_touch_items)
# test-touch : ${test_touch_items}/.success
set(ldeps "${regular_test_touch_items}")
add_custom_target( test-touch DEPENDS ${ldeps})
add_custom_target(libiomp-test-touch DEPENDS ${ldeps})
if(${WINDOWS})
# pick test-touch compiler
@ -108,8 +107,7 @@ if(NOT ${MIC} AND ${test_touch} AND ${tests})
list(APPEND tt-env "KMP_VERSION=1")
macro(test_touch_recipe test_touch_dir)
file(MAKE_DIRECTORY ${build_dir}/${test_touch_dir})
set(ldeps ${src_dir}/test-touch.c ${build_dir}/${lib_file})
set(ldeps ${src_dir}/test-touch.c lib)
set(tt-exe-file ${test_touch_dir}/test-touch${exe})
if(${WINDOWS})
# ****** list(APPEND tt-c-flags -Fo$(dir $@)test-touch${obj} -Fe$(dir $@)test-touch${exe}) *******
@ -121,6 +119,7 @@ if(NOT ${MIC} AND ${test_touch} AND ${tests})
endif()
add_custom_command(
OUTPUT ${test_touch_dir}/.success
COMMAND ${CMAKE_COMMAND} -E make_directory ${build_dir}/${test_touch_dir}
COMMAND ${CMAKE_COMMAND} -E remove -f ${test_touch_dir}/*
COMMAND ${tt-c} ${tt-c-flags-out} ${tt-c-flags} ${src_dir}/test-touch.c ${tt-libs} ${tt-ld-flags}
COMMAND ${CMAKE_COMMAND} -E remove -f ${tt-exe-file}
@ -137,94 +136,40 @@ if(NOT ${MIC} AND ${test_touch} AND ${tests})
else()
test_touch_recipe(test-touch-rt)
endif()
else()
add_custom_target(test-touch DEPENDS test-touch/.success)
macro(test_touch_recipe_skip test_touch_dir)
if(${tests} AND ${test_touch})
set(test_touch_message 'test-touch is not available for the Intel(R) MIC Architecture. Will not perform it.')
else()
set(test_touch_message "test-touch is turned off. Will not perform it.")
endif()
add_custom_command(
OUTPUT ${test_touch_dir}/.success
COMMAND ${CMAKE_COMMAND} -E echo ${test_touch_message}
)
endmacro()
test_touch_recipe_skip(test-touch-rt)
test_touch_recipe_skip(test-touch-mt)
test_touch_recipe_skip(test-touch-md)
endif()
# test-relo
add_custom_target(test-relo DEPENDS test-relo/.success)
if(${LINUX} AND ${test_relo} AND ${tests})
file(MAKE_DIRECTORY ${build_dir}/test-relo)
add_custom_target(libiomp-test-relo DEPENDS test-relo/.success)
add_custom_command(
OUTPUT test-relo/.success
COMMAND ${CMAKE_COMMAND} -E make_directory ${build_dir}/test-relo
COMMAND readelf -d ${build_dir}/${lib_file} > test-relo/readelf.log
COMMAND grep -e TEXTREL test-relo/readelf.log \; [ $$? -eq 1 ]
COMMAND ${CMAKE_COMMAND} -E touch test-relo/.success
DEPENDS ${build_dir}/${lib_file}
DEPENDS lib
)
else()
if(${tests} AND ${test_relo})
set(test_relo_message 'test-relo is only available for dynamic library on Linux or Intel(R) MIC Architecture. Will not perform it.')
else()
set(test_relo_message "test-relo is turned off. Will not perform it.")
endif()
add_custom_command(
OUTPUT test-relo/.success
COMMAND ${CMAKE_COMMAND} -E echo ${test_relo_message}
)
endif()
# test-execstack
add_custom_target(test-execstack DEPENDS test-execstack/.success)
if(${LINUX} AND ${test_execstack} AND ${tests})
file(MAKE_DIRECTORY ${build_dir}/test-execstack)
add_custom_target(libiomp-test-execstack DEPENDS test-execstack/.success)
add_custom_command(
OUTPUT test-execstack/.success
COMMAND ${CMAKE_COMMAND} -E make_directory ${build_dir}/test-execstack
COMMAND ${PERL_EXECUTABLE} ${tools_dir}/check-execstack.pl ${oa_opts} ${build_dir}/${lib_file}
COMMAND ${CMAKE_COMMAND} -E touch test-execstack/.success
DEPENDS ${build_dir}/${lib_file}
DEPENDS lib
)
else()
if(${tests} AND ${test_execstack})
set(test_execstack_message "test-execstack is only available for dynamic library on Linux. Will not perform it.")
else()
set(test_execstack_message "test-execstack is turned off. Will not perform it.")
endif()
add_custom_command(
OUTPUT test-execstack/.success
COMMAND ${CMAKE_COMMAND} -E echo ${test_execstack_message}
)
endif()
# test-instr
add_custom_target(test-instr DEPENDS test-instr/.success)
if(${MIC} AND ${test_instr} AND ${tests})
file(MAKE_DIRECTORY ${build_dir}/test-instr)
add_custom_target(libiomp-test-instr DEPENDS test-instr/.success)
add_custom_command(
OUTPUT test-instr/.success
COMMAND ${CMAKE_COMMAND} -E make_directory ${build_dir}/test-instr
COMMAND ${PERL_EXECUTABLE} ${tools_dir}/check-instruction-set.pl ${oa_opts} --show --mic-arch=${mic_arch} ${build_dir}/${lib_file}
COMMAND ${CMAKE_COMMAND} -E touch test-instr/.success
DEPENDS ${build_dir}/${lib_file} ${tools_dir}/check-instruction-set.pl
DEPENDS lib ${tools_dir}/check-instruction-set.pl
)
else()
if(${tests} AND ${test_instr})
set(test_instr_message 'test-instr is only available for Intel(R) MIC Architecture libraries. Will not perform it.')
else()
set(test_instr_message "test-instr is turned off. Will not perform it.")
endif()
add_custom_command(
OUTPUT test-instr/.success
COMMAND ${CMAKE_COMMAND} -E echo ${test_instr_message}
)
endif()
# test-deps
add_custom_target(test-deps DEPENDS test-deps/.success)
if(${test_deps} AND ${tests})
add_custom_target(libiomp-test-deps DEPENDS test-deps/.success)
set(td_exp)
if(${FREEBSD})
set(td_exp libc.so.7 libthr.so.3 libunwind.so.5)
@ -262,24 +207,12 @@ if(${test_deps} AND ${tests})
endif()
endif()
endif()
file(MAKE_DIRECTORY ${build_dir}/test-deps)
add_custom_command(
OUTPUT test-deps/.success
COMMAND ${CMAKE_COMMAND} -E make_directory ${build_dir}/test-deps
COMMAND ${PERL_EXECUTABLE} ${tools_dir}/check-depends.pl ${oa_opts} --expected="${td_exp}" ${build_dir}/${lib_file}
COMMAND ${CMAKE_COMMAND} -E touch test-deps/.success
DEPENDS ${build_dir}/${lib_file} ${tools_dir}/check-depends.pl
DEPENDS lib ${tools_dir}/check-depends.pl
)
else()
if(${tests} AND ${test_deps})
set(test_deps_message 'test-deps is available for dynamic libraries on Linux, Mac, Intel(R) MIC Architecture, Windows and static libraries on Windows. Will not perform it.')
else()
set(test_deps_message "test-deps is turned off. Will not perform it.")
endif()
add_custom_command(
OUTPUT test-deps/.success
COMMAND ${CMAKE_COMMAND} -E echo ${test_deps_message}
)
endif()
# END OF TESTS
######################################################