Skip to content

blt::openmp INTERFACE_COMPILE_OPTIONS may not delimit lists correctly. #723

@eirrgang

Description

@eirrgang

blt_add_target_compile_flags() does not prefix SHELL: the way blt_add_target_link_flags() does. This means that BLTSetupOpenMP.cmake gets multiple arguments in the ${OpenMP_CXX_FLAGS} string, we get a single list element containing a space instead of a semicolon delimited list of arguments.

The OpenMP::OpenMP_CXX target deals with this by prefixing SHELL:, so that seems like a reasonable approach.

For a failure case, consider that the Apple Clang compilers with libomp from Homebrew require '-Xclang -fopenmp'. Configure the following CMake project with -DOpenMP_ROOT=/opt/homebrew/opt/libomp.

cmake_minimum_required(VERSION 3.15)
project(testbltopenmp)

set(ENABLE_OPENMP TRUE)

include(blt/SetupBLT.cmake)

blt_print_target_properties(TARGET blt::openmp)
blt_print_target_properties(TARGET OpenMP::OpenMP_CXX)

Result:

...

Problems were encountered while collecting compiler information:
	clang++: error: unknown argument: '-Xclang -fopenmp'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions