With cmake, I am trying to create a Visual Studio 2022 solution that supports two platforms for an exe and lib. The first platform being x64, and the second being a second platform called “tools”.
The approach for doing this that I read has said to create a CMakeLists.txt, then make a CMakeLists for each project per platform. However, when attempting that approach, it is not possible due to them having the same exe name from add_executable (or same library name, through add_library). However, I would want them to have the same name. What I would like to know, how can I support two different platforms inside of a solution while maintaining the same exe or lib name?
If it is impossible to have both platforms in one solution, then what is the recommended solution? Do I have a solution per platform and in my exe and libs CMakeLists.txt I set what platform to use based upon a drop down from my CMake gui?
As an example, here is my current setp
CMakeLists.txt
cmake_minimum_required(VERSION 3.28)
project(GlobalProject)
add_subdirectory(Testing-tools)
add_subdirectory(Testing-x64)
Testing-tools\CMakeLists.txt
cmake_minimum_required(VERSION 3.28)
set(CMAKE_GENERATOR_PLATFORM tools)
project(Testing-tools CXX)
add_executable(TestFlags ../main.cpp)
Testing-x64\CMakeLists.txt
cmake_minimum_required(VERSION 3.28)
set(CMAKE_GENERATOR_PLATFORM x64tools)
project(Testing-x64 CXX)
add_executable(TestFlags ../main.cpp)