CMAKE_BUILD_TYPE does not work in CMAKE_TOOLCHAIN_FILE - how to proceed?
I'm new to cmake and we started using it to build proprietary embedded
projects with a proprietary toolchain. We love the new build system's
performance and its simplicity! Compared with what we were used to
have, it is just superior in every aspect we met, really great!
We hopefully based our approach correctly based on examples found in
the web, stackoverflow answers, tutorials and of course the cmake
documentation. For each embedded system toolchain (i.e. device, major
lib versions etc) we wrote a CMAKE_TOOLCHAIN_FILE, which sets
CMAKE_C_COMPILER, CMAKE_C_FLAGS and so on. We needed to use the force
(CACHE STRING "" FORCE).
What is left open is to select debug or release binaries. I googled a
lot, but unfortunately did not find a solution, so I hope you please
can point me into the right direction.
I think a (non-working) example illustrates pretty clear what I would
like to archive. Having in ToolchainFile.cmake:
This unfortunately does not work, because the Toolchain file is
included / executed multiple times and at least one inclusions have
CMAKE_BUILD_TYPE empty. --trace shows that some CMake own file
Do you have any hint how to do this correctly? Some workaround? Should
we somehow save the value in an own variable and use this own variable
if set (if this is possible at all)? Or are we supposed to have a
different toolchain file for Debug and Release (would double the
number of files)? We could also consider adding an own
"-DXYZ_CMAKE_BUILD_TYPE=Debug" variable, would this be suited?
What would be the best and "most standard" way to handle Debug and
Release libraries in an own toolchain?