[CMake] how to specify a different source directory
aaron.meadows at thomsonreuters.com
aaron.meadows at thomsonreuters.com
Thu Feb 2 22:20:03 EST 2012
That sounds about right to me. (though personally, I like to make my
tests include the files they are testing by linking to a library
containing them...)
If you wanted to abstract the location away from the test code, you
could set a variable containing the source files in a higher (or
earlier) CMake scope and use that variable to within the deeper scope to
add them to your executable.
/foo/CMakeLists.txt
#[...]
set(FilesToIncludeInTestExe
${CMAKE_CURRENT_LIST_DIR}/file1.cpp
${CMAKE_CURRENT_LIST_DIR}/file2.cpp
${CMAKE_CURRENT_LIST_DIR}/file3.cpp
${CMAKE_CURRENT_LIST_DIR}/file4.cpp
)
#[...]
/foo/foo_test/CMakeLists.txt
#[...]
add_executable(foo_test ${fooTestFiles} ${FilesToIncludeInTestExe} )
#[...]
Some other alteratives might be to set a Global or target property in
the parent CMakeLists.txt and read it in the child one.
Aaron Meadows
-----Original Message-----
From: cmake-bounces at cmake.org [mailto:cmake-bounces at cmake.org] On Behalf
Of Dev Guy
Sent: Thursday, February 02, 2012 8:11 PM
To: CMake mailing list
Subject: Re: [CMake] how to specify a different source directory
On Thu, Feb 2, 2012 at 7:46 PM, Dev Guy <devguy.ca at gmail.com> wrote:
> I have a project file and within it I have created a test folder and
> placed some testing code there. From my test CMakelist, I need to
> access a .cpp file from the parent folder but I am not sure how to do
> this?
>
> Thus the call to add_executable fails because it can't locate the
source file.
>
OK I figured out when I pass in the source file to add_executable, I
just need to prefix the source file with "../"
Is this the proper way to do it, or should I be using another cmake
command to declare a source folder?
Thanks,
Rajinder
--
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
This email was sent to you by Thomson Reuters, the global news and information company. Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of Thomson Reuters.
More information about the CMake
mailing list