[cmake] Fix single config generators handling (#3794)
* Add `USE_BUILD_TYPE_SUBFOLDER` CMake option to append `CMAKE_BUILD_TYPE` to output binary directory. Initialize it to `ON` for UNIX to keep current behavior. * Remove forced `CMAKE_CONFIGURATION_TYPES` initialization, use user provided value instead. This will allow to use single config generators (like Ninja) on Windows with MSVC compilers and get binaries in per-config sub-folders in the same way as on UNIX. Co-authored-by: Ilya Lavrenov <ilya.lavrenov@intel.com>
This commit is contained in:
1 parent
09a2d2a525
commit
8ec38cf039
4 files changed
+33
-25
No files matched your search
@@ -116,6 +116,11 @@ else()
|
||||
message(FATAL_ERROR "CMAKE_BUILD_TYPE must be one of Debug, Release, RelWithDebInfo, or MinSizeRel")
|
||||
endif()
|
||||
endif()
|
||||
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
|
||||
|
||||
if(USE_BUILD_TYPE_SUBFOLDER)
|
||||
set(BIN_FOLDER "${BIN_FOLDER}/${CMAKE_BUILD_TYPE}")
|
||||
endif()
|
||||
|
||||
# allow to override default OUTPUT_ROOT root
|
||||
if(NOT DEFINED OUTPUT_ROOT)
|
||||
@@ -151,30 +156,25 @@ if (MSVC OR CMAKE_GENERATOR STREQUAL "Xcode")
|
||||
# Support CMake multiconfiguration for Visual Studio or Xcode build
|
||||
set(IE_BUILD_POSTFIX $<$<CONFIG:Debug>:${IE_DEBUG_POSTFIX}>$<$<CONFIG:Release>:${IE_RELEASE_POSTFIX}>)
|
||||
else ()
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "Debug" )
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set(IE_BUILD_POSTFIX ${IE_DEBUG_POSTFIX})
|
||||
else()
|
||||
set(IE_BUILD_POSTFIX ${IE_RELEASE_POSTFIX})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
|
||||
|
||||
add_definitions(-DIE_BUILD_POSTFIX=\"${IE_BUILD_POSTFIX}\")
|
||||
|
||||
if(NOT UNIX)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
|
||||
set(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
|
||||
set(CMAKE_PDB_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
|
||||
else()
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE}/lib)
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE}/lib)
|
||||
set(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE})
|
||||
set(CMAKE_PDB_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE})
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE})
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER}/lib)
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER}/lib)
|
||||
endif()
|
||||
set(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
|
||||
set(CMAKE_PDB_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
|
||||
|
||||
if(APPLE)
|
||||
set(CMAKE_MACOSX_RPATH ON)
|
||||
|
||||
@@ -11,6 +11,12 @@ ie_dependent_option (ENABLE_LTO "Enable Link Time Optimization" OFF "LINUX;NOT C
|
||||
|
||||
ie_option (OS_FOLDER "create OS dedicated folder in output" OFF)
|
||||
|
||||
if(UNIX)
|
||||
ie_option(USE_BUILD_TYPE_SUBFOLDER "Create dedicated sub-folder per build type for output binaries" ON)
|
||||
else()
|
||||
ie_option(USE_BUILD_TYPE_SUBFOLDER "Create dedicated sub-folder per build type for output binaries" OFF)
|
||||
endif()
|
||||
|
||||
# FIXME: ARM cross-compiler generates several "false positive" warnings regarding __builtin_memcpy buffer overflow
|
||||
ie_dependent_option (TREAT_WARNING_AS_ERROR "Treat build warnings as errors" ON "X86 OR X86_64" OFF)
|
||||
|
||||
|
||||
Reference in new issue
Block a user