开发者

What is the correct way to customize the install output directory for each developer in CMake?

I've been working on an old game that I created CMake files for to get rid of a mix of Makefiles and visual studio projects. Everything is working well, but I'm having a hard time figuring out what the correct way to allow the developer to specify where the output files are copied to when install is run.

The issue is there are many DLLs and some custom targets that need their output copied into a directory structure that includes the game data (levels, art, sound, etc) before they can test the code.

My install commands currently uses a variable that I 'SET' at the top level CMakeLists.txt to specify the output dir开发者_开发百科ectory. I've tried overriding it with -DD3_GAMEDIR on the cmake command line. That variable gets set in the CMakeCache, but the SET command appears to override it still.

Should I be checking the length of the variable before using SET to see if the user specified a value? That seems like a hack to me, but I'm having a hard time finding the correct way to do it.

Thanks!


The install target supports the DESTDIR parameter, so you could do something like:

make install DESTDIR="C:\RootGameDir"

The other option is to only set the variable if it isn't already set (if(myVar)), but I personally prefer the DESTDIR solution.


Here is the anwser, according your cmake version:

SET(CMAKE_VERSION "${CMAKE_CACHE_MAJOR_VERSION}.${CMAKE_CACHE_MINOR_VERSION}")
IF("${CMAKE_VERSION}" STRGREATER "2.4")
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY /path/of/your/install/${CMAKE_BUILD_TYPE}/bin)
SET(CMAKE_LIBRARY_OUTPUT_PATH /path/of/your/install/${CMAKE_BUILD_TYPE}/lib)
ELSE("${CMAKE_VERSION}" STRGREATER "2.4")
SET(EXECUTABLE_OUTPUT_PATH /path/of/your/install/${CMAKE_BUILD_TYPE}/bin)
SET(LIBRARY_OUTPUT_PATH /path/of/your/install/${CMAKE_BUILD_TYPE}/lib)
ENDIF("${CMAKE_VERSION}" STRGREATER "2.4")


What about using the various CMAKE_INSTALL_PREFIX, PROJECT_SOURCE_DIR and PROJECT_BINARY_DIR?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜