当前位置: 动力学知识库 > 问答 > 编程问答 >

mingw - CMake, build 64 bit on 32 bit machine

问题描述:

I am using make to build my project. I have glfw as a dependency, it uses cmake to generate the Makefile. This is how I call cmake from my Makefile:

glfw:

$(MKDIR) $(CBUILD_PATH)$(PATH_SEP)glfw

ifeq ($(OS),"MinGW")

cd $(CBUILD_PATH)$(PATH_SEP)glfw && \

cmake -G "MSYS Makefiles" -DBUILD_SHARED_LIBS=ON -DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF ..$(PATH_SEP)..$(PATH_SEP)src$(PATH_SEP)c$(PATH_SEP)glfw

cd $(CBUILD_PATH)$(PATH_SEP)glfw && $(MAKE) $(MFLAGS)

cd $(CBUILD_PATH)$(PATH_SEP)glfw$(PATH_SEP)src && echo "..\..\..\$(IMPLIB) /s glfw3.lib glfw3.dll && exit;" | cmd

else

cd $(CBUILD_PATH)$(PATH_SEP)glfw && \

cmake -DBUILD_SHARED_LIBS=OFF -DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF ..$(PATH_SEP)..$(PATH_SEP)src$(PATH_SEP)c$(PATH_SEP)glfw

cd $(CBUILD_PATH)$(PATH_SEP)glfw && $(MAKE) $(MFLAGS)

endif

Not very elegant but it works. I can specify a -m64 flag for GCC to build 64 bit binaries on a 32 bit machine but I don't know how to make cmake add this flag to the command line (without patching the CMakeLists.txt). It feels like there most be a commandline solution, but I wasn't able to find it.

Note, I need this mainly for Windows, I am using MinGW/Msys there.

网友答案:

You need to detect your arch in the Makefile and then conditionally add

-D CMAKE_{C,CXX}_FLAGS=-m64

to the cmake call.

分享给朋友:
您可能感兴趣的文章:
随机阅读: