Ninja: cmake 3.17 CMAKE_BUILD_TYPE regressions
Starting cmake 3.17.0 setting the CMAKE_BUILD_TYPE
when importing subdirectories stops working.
Consider the main project is build with -DCMAKE_BUILD_TYPE=RelWithDebInfo
, but some external target should always be built in release mode. The following worked fine until (including) 3.16.6:
function(load_omp)
# Intel/llvm OpenMP
set(OPENMP_STANDALONE_BUILD TRUE)
set(LIBOMP_ENABLE_SHARED TRUE)
set(CMAKE_BUILD_TYPE Release)
set(OPENMP_ENABLE_LIBOMPTARGET OFF CACHE BOOL "LLVM OpenMP offloading support")
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/openmp)
# Disable warnings
target_compile_options(omp PRIVATE
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:-w>
$<$<CXX_COMPILER_ID:MSVC>:/w>)
endfunction()
load_omp()
target_link_libraries(target PUBLIC omp)
However, starting with cmake 3.17, cmake generates a ninja file declaring how to build cmake_object_order_depends_target_omp_Release
(correct) but having target
depend on cmake_object_order_depends_target_omp_RelWithDebInfo
which does not exist. Thus ninja
presents the error ninja: error: 'cmake_object_order_depends_target_omp_RelWithDebInfo', needed by [...], missing and no known rule to make it