View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0012543CMakeCMakepublic2011-10-27 19:002011-10-27 22:46
ReporterTony Bridges 
Assigned ToClinton Stimpson 
PriorityhighSeverityfeatureReproducibilityalways
StatusclosedResolutionno change required 
Platformx86OSWin2k8OS Version
Product VersionCMake-2-8 
Target VersionFixed in Version 
Summary0012543: Cannot specify link_libraries per configuration when using custom configurations
DescriptionRelated to 0012124, added to refine the requirement.

In my project, I need to build a particular shared project a number of different ways (Debug/Release Shared/Static MBCS/Unicode in all combinations). These are implemented as multiple configurations via CMAKE_CONFIGURATION_TYPES. (Debug, Debug-Shared, Debug-Shared-Unicode for example)

At the project level, I need to specify different support libraries by name, based on the configuration. For example, for static debug I reference cppunitd.lib, and for shared debug I reference cppunitd-sh.lib.

The support for conditional libraries in the target_link_libraries command is limited to the standard configurations, Debug, Release, Optimized. Custom configurations are not recognized here.

What is needed is the ability to use custom configurations in the target_link_libraries command to set library names per configuration.

The same argument applies to setting the library path (and to a lesser extent, the include path). Currently, these can only be set per-configuration at the solution level (via set(CMAKE_CXX_FLAGS_DEBUG_SHARED_UNICODE) ), which requires that the conditional paths for all libraries in the solution be set globally. This results in a potentially dangerous superset of LIBPATHS being pushed into every project in the solution, and loss of control over order and precedence.
  
Additional Informationto summarize, looking for features as follows :

target_link_libraries ( {MyCustomConfigName} {MyLibByConfigName} )

link_directories ( {MyCustomConfigName} {MyLibPath} )

include_directories ( {MyCustomConfigName} {MyIncPath} )
TagsCMake, visual studio
Attached Files

 Relationships

  Notes
(0027664)
Clinton Stimpson (developer)
2011-10-27 19:12

That should already be possible using an imported library

add_library(mylib UNKNOWN IMPORTED)
set_target_properties(mylib PROPERTIES
  IMPORTED_LOCATION_DEBUG "/path/to/debug"
  IMPORTED_LOCATION_UNICODE "/path/to/unicode"
  ... etc... )

..

target_link_libraries(myexecutable mylib)

You can also set compile flags on a per-configuration bases on the targets.

Feel free to ask for more help on the mailing list.
(and avoid deprecated things like 'link_directories()')
(0027665)
Tony Bridges (reporter)
2011-10-27 19:36

Tried and working. I should have posted the issue to the list first :) Thanks Clinton.

 Issue History
Date Modified Username Field Change
2011-10-27 19:00 Tony Bridges New Issue
2011-10-27 19:04 Tony Bridges Tag Attached: CMake
2011-10-27 19:05 Tony Bridges Tag Attached: static library
2011-10-27 19:05 Tony Bridges Tag Attached: visual studio
2011-10-27 19:05 Tony Bridges Tag Detached: static library
2011-10-27 19:12 Clinton Stimpson Note Added: 0027664
2011-10-27 19:36 Tony Bridges Note Added: 0027665
2011-10-27 22:46 Clinton Stimpson Status new => closed
2011-10-27 22:46 Clinton Stimpson Assigned To => Clinton Stimpson
2011-10-27 22:46 Clinton Stimpson Resolution open => no change required


Copyright © 2000 - 2018 MantisBT Team