c语言编译 64位,cmake – 编译32位和64位
正如我在評(píng)論中所說(shuō),這是我們?nèi)绾巫龅竭@一點(diǎn)的一個(gè)例子.
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}
)
它對(duì)我們來(lái)說(shuō)效果很好,即使在我們的生產(chǎn)過(guò)程中也是如此.
它允許top為我們的配置做好準(zhǔn)備:32位和64位.之后我們必須在兩個(gè)平臺(tái)上構(gòu)建.
總結(jié)
以上是生活随笔為你收集整理的c语言编译 64位,cmake – 编译32位和64位的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: linux音频时钟bclk,linux
- 下一篇: C语言两班平均成绩,两班工人的平均日产量