ExternalProject_Add Does Not Set Project Release Configuration

EDIT: I found a probable reason, but I donโ€™t understand why: the last line below the script Project(Externals) when deleting fixes my problem. So now the question is: why?

 cmake_minimum_required(VERSION 2.8) include(ExternalProject) MACRO(EXTERNAL_DEF aNewTargetName aPathToSource) ExternalProject_Add( ${aNewTargetName} PREFIX ${CMAKE_INSTALL_PREFIX} SOURCE_DIR ${aPathToSource} TMP_DIR "${CMAKE_INSTALL_PREFIX}/tmp/${CMAKE_BUILD_TYPE}" DOWNLOAD_DIR "${CMAKE_INSTALL_PREFIX}/src/${CMAKE_BUILD_TYPE}" BINARY_DIR "${CMAKE_INSTALL_PREFIX}/src/${CMAKE_BUILD_TYPE}/${aNewTargetName}-build" STAMP_DIR "${CMAKE_INSTALL_PREFIX}/src/${CMAKE_BUILD_TYPE}/${aNewTargetName}-stamp" CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} --debug-output BUILD_COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_INSTALL_PREFIX}/src/${CMAKE_BUILD_TYPE}/${aNewTargetName}-build" --config "${CMAKE_BUILD_TYPE}" #INSTALL_DIR "${CMAKE_INSTALL_PREFIX}" ) ENDMACRO() get_filename_component(zlibAbsPath "./zlib" ABSOLUTE) EXTERNAL_DEF(zlib_external ${zlibAbsPath}) Project(Externals) 

I call cmake in the above CMakeLists.txt file with CMAKE_INSTALL_PREFIX to say "d: \ externals" and CMAKE_BUILD_TYPE set "Release"

Expectation: I would expect only the Release configuration to be built. And after it is built, I expect it to be installed in D:\externals\bin\zlib.dll .

Problem: Actually, ExternalProject_Add creates both Debug and Release and installs the debug version of the dll in D:\externals\bin\zlibd.dll

Is my build script correct? What am I doing wrong?

EDIT: some more info. I just noticed. In the generated D: \ externals \ src \ Release \ zlib_external-build \ zlib.sln, the INSTALL target is not selected for assembly at all. If I check it for creating the Release configuration, click Build from visual studio, the INSTALL target builds and installs the files I expect them to be. I have no idea what's going on ...

+4
source share
2 answers

CMAKE_BUILD_TYPE only works with projects with one configuration

you can change to:

 .... BUILD_COMMAND "" INSTALL_COMMAND cmake --build . --target install --config Release BUILD_ALWAYS 1 ... 
+1
source

Use the DCMAKE_CFG_INTDIR variable.

 ... CMAKE_ARGS ... -DCMAKE_CFG_INTDIR=Release 
-3
source

Source: https://habr.com/ru/post/1479237/


All Articles