[CMake] Get configuration-dependant LOCATION property

Mateusz Loskot mateusz at loskot.net
Tue Oct 5 17:25:29 EDT 2010


On 05/10/10 02:52, Michael Hertling wrote:
> On 10/04/2010 11:15 PM, Mateusz Loskot wrote:
>> 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\"
> 
> You might consider to use a script as a test driver which takes
> the desired path and the test executable as parameters, e.g.
> 
> ADD_TEST(mytest
>     testdriver $<TARGET_FILE_DIR:mylib> $<TARGET_FILE:mytest>)
> 
> with testdriver setting the PATH and executing mytest.


I admit, such script has a lot of potential to tweak runtime environment
indeed.

At this moment I'm happy with output all binary modules in build/bin and
build/lib, so I have no need to set extra env any more.

I'll keep in mind the idea though. Thanks.

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