Make file has x86 and x64 build targets
已回答
I'm using CLion 2017.3.3 and our main CMakeList.txt has a target to either build in x86 or x64 on RHEL. How do I set CLion to build either? The x86 or x64?
I've used MS VS and there you can easily select between x86 or x64. So, I was wondering how to do that with CLion since the CMakeList.txt file has both. Here's how that's setup:
...
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
if (${TARGET_64} MATCHES ON)
set(BUILD_ARCH "-m64")
else ()
set(BUILD_ARCH "-m32")
endif ()
...
I cannot change the list file since that's under someone else's control and they won't change it just for me since most of the other S/W Engineers use Eclipse.
Thx.
请先登录再写评论。
No idea huh?
Hi, Larry! In order to compile your project as 32-bit or 64-bit need to pass -m32 or -m64 option to compiler/linker. This is already implemented in the CMakeLists.txt of your project, as I understand. What is the TARGET_64 variable? Where is it set?
Is there a way to change it within the application without editing the make file? Like what can be done within Visual Studio?
Since the logic in your CMakeLists.txt depends on the TARGET_64 variable, you can do the following:
Create two CMake profiles (https://www.jetbrains.com/help/clion/configuring-cmake.html#CMProfile) and specify -DTARGET_64=ON in CMake options in the first profile and DTARGET_64=OFF in the second. After that you will be able to select the necessary CMake Profile in the run configuration switcher on the toolbar to build a target using a specific profile: