Hello,

We have a modular in-house library that we use for our software.  Let’s call it 
lib_x.  Let’s call a few of the modules (we have 7 I think) mod_y, mod_z, mod_u 
and mod_v.  Let’s say I have two applications that use all of this and call 
them app_1 and app_2.

The way I have setup our CMake builds is that I first find out what modules of 
lib_x the applications app_1 and app_2 depend on.  Then I build a single 
library lib_x which include the selected modules and finally, I build each app 
independently and link against the single library.

For instance, let’s say app_1 depends on mod_y and mod_z and app_2 depends on 
mod_y, mod_z and mod_u.  Then, I would build lib_x with everything for modules 
y, z and u (excluding module v) and build app_1 and app_2 linking against lib_x

Might not be explained properly (my apologies), willing to answer any questions 
on that.

I am looking into changing/modernizing our build system.  From what I 
understand, instead of building everything into a single library, I could build 
separate libraries, export them as targets and link against them.  (Pretty sure 
I could have done that before, but just coming around to do it.)

Am I wrong ?  Am I completely missing the point ?  If I am not and it is a 
reasonable approach, is there a place where a tutorial is available ?  I am 
trying really hard to read the documentation on export command and targets and 
such, but I am having a real hard time when trying to actually implement 
anything concrete.

I first attempted to do this:
include_directories( "${LIB_ROOT_DIR}/include" )
add_library( general ${GENERAL_SRCS}
                     ${GENERAL_HDRS}
                     ${LIB_ROOT_DIR}/include/hdqrt/always_inline.h
                     ${LIB_ROOT_DIR}/include/hdqrt/debug.h
                     ${LIB_ROOT_DIR}/include/hdqrt/Error.h
                     ${LIB_ROOT_DIR}/include/hdqrt/warn_stop.h
                     ${LIB_ROOT_DIR}/include/hdqrt/warn_restart.h
            )
set_property( TARGET general PROPERTY CXX_STANDARD 14 )
export( TARGETS general FILE general.cmake )

but then, the general.cmake file is nowhere to be found.  And if I test in 
another (parent) CMakeLists.txt to see if the target is defined, it is not.

Sorry if this is a silly question.  Trying to figure this out.

Thanks in advance.
Ghyslain
-- 

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

Reply via email to