更新时间:2022-05-24 01:48:59
正如我在评论中所说,这是我们如何做到的示例。
As I said in my comment, here is an example of how we did that.
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}
)
即使在生产过程中,它也对我们很好。
It's working well for us, even in our production process.
它允许上面同时为两个做好准备:32和64位。之后,我们必须在两个平台中构建。
It permits top have our configuration ready for both : 32 and 64 bits. After that we have to build in both platform.