Thanks for the reply. In my case, I didn't even want the CMakeLists in the top-level dir. I didn't want to contaminate my top-level dir with anything related to CMake. This would avoid, for example, an accidental overwrite of an existing Makefile if one was to do a 'cmake .' in the the top dir.
It's quite possible I'm over-thinking this; I was just curious if it's even possible. Seems like it should be. -Randy On Wed, Oct 4, 2017 at 4:30 PM, J. Caleb Wherry <[email protected]> wrote: > There is no reason why this shouldn't work, I do something similar where > everything except my top-level CMakeLists is shoved into a subdirectory > (away from the src code location). > > You don't have to muck with the project macro at all, not sure what you > are trying to accomplish with that? That just sets the name of the project. > > All you have to be aware of is all the paths are now with respect to both > the CMakeLists and where ever you put your binary dir. So doing something > like the below allows you to reference things in your source tree > (depending on how far you away form the root, obviously): > > get_filename_component(SourceRoot "${CMAKE_CURRENT_SOURCE_DIR}/../../" > ABSOLUTE) > > The normal structure of the CMake file doesn't change, nothing special has > to be done with the project macro. Unless you have a more specific error, > that's about all the advice I have. > > -Caleb > > > On Wed, Oct 4, 2017 at 3:16 PM, Randy Heiland <[email protected]> > wrote: > >> Hello, >> >> Simple question... can I/how can I keep my top-level cmake-related stuff >> in a subdirectory of my main project directory? E.g.: >> >> /myproj >> /cmake >> CMakeLists.txt >> >> and then in the /cmake, I create a /build from which I attempt: cmake .. >> >> I tried something as simple as this in my CMakeLists.txt, but it didn't >> seem to work: >> project (../myproj) >> >> >> The primary reason I'd like to do this is to hide/make optional the cmake >> build approach (and keep in place an existing/traditional Makefile in the >> parent directory). Play along... >> >> thanks, Randy >> >> -- >> >> Powered by www.kitware.com >> >> Please keep messages on-topic and check the CMake FAQ at: >> http://www.cmake.org/Wiki/CMake_FAQ >> >> Kitware offers various services to support the CMake community. For more >> information on each offering, please visit: >> >> CMake Support: http://cmake.org/cmake/help/support.html >> CMake Consulting: http://cmake.org/cmake/help/consulting.html >> CMake Training Courses: http://cmake.org/cmake/help/training.html >> >> Visit other Kitware open-source projects at >> http://www.kitware.com/opensource/opensource.html >> >> Follow this link to subscribe/unsubscribe: >> http://public.kitware.com/mailman/listinfo/cmake >> > > > > -- > J. Caleb Wherry > *Scientific Software Engineer* > > <http://www.calebwherry.com> > http://www.calebwherry.com > +1 (615) 708-5651 <(615)%20708-5651> > [email protected] >
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake
