MantisBT - CMake
View Issue Details
0014702CMake(No Category)public2014-01-16 06:392014-06-02 08:38
Mattes D 
 
normalmajoralways
closedno change required 
Windows AnyWindowsAny
CMake 2.8.11.2 
 
0014702: PREFIX property is ignored for Visual Studio 2010+ generators
The Visual Studio 2010+ generator, as implemented in cmVistualStudio10Target.cpp, seems to half-ignore the setting of the PREFIX property. The executable is built without this prefix, although the PDB files do contain the prefix.

The Visual Studio 2008 and lower generators do handle the property as expected, which brings even more chaos.
We use the following code in our CMakeLists.txt:

```
add_executable(${EXECUTABLE} ${SOURCE})

set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin)
set_target_properties(${EXECUTABLE} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)

if (MSVC)
    # MSVC generator adds a "Debug" or "Release" postfixes to the EXECUTABLE_OUTPUT_PATH, we need to cancel them:
    SET_TARGET_PROPERTIES(${EXECUTABLE} PROPERTIES PREFIX "../")
    SET_TARGET_PROPERTIES(${EXECUTABLE} PROPERTIES IMPORT_PREFIX "../")
endif()
```

In the MSVC2008 generator the executable correctly generates in the $/bin/ folder; MSVC2010+ generators generate the executable in $/bin/<configuration>/ folder instead.
The full CMakeLists.txt is available at https://github.com/mc-server/MCServer/blob/d67cd8dafc9d87fc5f26fd40c965e4234ac0f3b1/CMakeLists.txt [^]

The project using this file is at GitHub: https://github.com/mc-server/MCServer [^]

We actually test on MSVC2013, but this part of the projectfile generation seems to be shared among 2010, 2012 and 2013 in CMake sources.
No tags attached.
Issue History
2014-01-16 06:39Mattes DNew Issue
2014-01-16 09:46Brad KingNote Added: 0034952
2014-01-16 09:46Brad KingStatusnew => resolved
2014-01-16 09:46Brad KingResolutionopen => no change required
2014-06-02 08:38Robert MaynardNote Added: 0036084
2014-06-02 08:38Robert MaynardStatusresolved => closed

Notes
(0034952)
Brad King   
2014-01-16 09:46   
The PREFIX "../" trick for avoiding per-config subdirectories was never officially documented or supported. It just happened to work due to implementation details of the VS <= 9 generators.

Since CMake 2.8.2 you can set a per-config output directory:

http://www.cmake.org/cmake/help/v2.8.12/cmake.html#prop_tgt:RUNTIME_OUTPUT_DIRECTORY_CONFIG [^]
(0036084)
Robert Maynard   
2014-06-02 08:38   
Closing resolved issues that have not been updated in more than 4 months.