c语言编译 64位,cmake – 编译32位和64位
正如我在評論中所說,這是我們如何做到這一點的一個例子.
if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
MESSAGE( "64 bits compiler detected" )
SET( EX_PLATFORM 64 )
SET( EX_PLATFORM_NAME "x64" )
else( CMAKE_SIZEOF_VOID_P EQUAL 8 )
MESSAGE( "32 bits compiler detected" )
SET( EX_PLATFORM 32 )
SET( EX_PLATFORM_NAME "x86" )
endif( CMAKE_SIZEOF_VOID_P EQUAL 8 )
...
IF( EX_PLATFORM EQUAL 64 )
MESSAGE( "Outputting to lib64 and bin64" )
# ---------- Setup output Directories -------------------------
SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY
${YourSoftwarePath}/lib64
CACHE PATH
"Single Directory for all Libraries"
)
# --------- Setup the Executable output Directory -------------
SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY
${YourSoftwarePath}/bin64
CACHE PATH
"Single Directory for all Executables."
)
# --------- Setup the Executable output Directory -------------
SET (CMAKE_ARCHIVE_OUTPUT_DIRECTORY
${YourSoftwarePath}/lib64
CACHE PATH
"Single Directory for all static libraries."
)
ELSE( EX_PLATFORM EQUAL 64 )
# ---------- Setup output Directories -------------------------
SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY
${YourSoftwarePath}/lib
CACHE PATH
"Single Directory for all Libraries"
)
# --------- Setup the Executable output Directory -------------
SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY
${YourSoftwarePath}/bin
CACHE PATH
"Single Directory for all Executables."
)
# --------- Setup the Executable output Directory -------------
SET (CMAKE_ARCHIVE_OUTPUT_DIRECTORY
${YourSoftwarePath}/lib
CACHE PATH
"Single Directory for all static libraries."
)
ENDIF( EX_PLATFORM EQUAL 64 )
...
add_library(YourSoftware SHARED
${INCLUDES}
${SRC}
)
它對我們來說效果很好,即使在我們的生產過程中也是如此.
它允許top為我們的配置做好準備:32位和64位.之后我們必須在兩個平臺上構建.
總結
以上是生活随笔為你收集整理的c语言编译 64位,cmake – 编译32位和64位的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux音频时钟bclk,linux
- 下一篇: C语言两班平均成绩,两班工人的平均日产量