[CMake] Get configuration-dependant LOCATION property

Mateusz Loskot mateusz at loskot.net
Mon Oct 4 17:15:18 EDT 2010


On 04/10/10 14:24, Michael Hertling wrote:
> On 10/04/2010 10:53 AM, Mateusz Loskot wrote:
>> On 04/10/10 07:33, J Decker wrote:
>>> CMAKE_INSTALL_CONFIG_NAME I don't know if there's a simple flag like
>>> 'project supports multiple targets' so I have an if(MSVC) set(
>>> MULTI_TARGET) endif()  .... if( MULTI_TARGET ) Install( targets ...
>>> ${CMAKE_INSTALL_CONFIG_NAME ) else() isntall( ... ${CMAKE_BUILD_TYPE}
>>
>>
>> I need it before firing up install procedures.
>> I build.
>> I run tests (here I need to know location of build output per target).
> 
> Have you already taken a look at ADD_TEST()'s generator expressions like
> $<TARGET_FILE_DIR:tgt>? AFAIK, they've been introduced quite exactly to
> meet requirements such as yours.

Hmm, I've seen this expressions, but I'm not sure how it can be useful
because the expressions are used to generate test input.

My problem is about getting property to generate environment
for test before it is executed:

In one subtree of my sources, I have mylib target building mylib.dll
In another subtree, I have test. Next, I build and run test:

add_executable(mytest test.cpp)

target_link_libraries(mytest mylib_import.lib)

add_test(mytest ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/mytest)

set_tests_properties(mytest PROPERTIES
  ENVIRONMENT "PATH=c:\path\to\dir\with\mylib.dll\")

I need to figure out this: "c:\path\to\dir\with\mylib.dll\"

Best regards,
-- 
Mateusz Loskot, http://mateusz.loskot.net
Charter Member of OSGeo, http://osgeo.org
Member of ACCU, http://accu.org


More information about the CMake mailing list