c++ - Building dependencies with Cmake -


i'm new cmake , i'm trying figure out how build dependencies. project folders organized this:

scrubber  -- fileio  -- cdes  -- utilities  -- scrubber 

fileio, cdes, , utilities static libraries used executable in scrubber.

i want able execute single make command top dir build everything. if build each library independently, comes fine when execute top make. if don't ahead of time won't build dependencies and, not surprisingly, complains libraries weren't found.

so simple question: how cause system build libraries?

top level cmakelists in scrubber

cmake_minimum_required(version 3.2) project(scrubber)  set(cmake_cxx_flags "${cmake_cxx_flags} -std=c++11")  add_subdirectory(fileio) add_subdirectory(cdes) add_subdirectory(utilities) add_subdirectory(scrubber) 

fileio cmakelists in scrubber/fileio

cmake_minimum_required(version 3.2) project(fileio)  set(cmake_cxx_flags "${cmake_cxx_flags} -std=c++11")  file(glob source_files *.cpp)  add_library(fileio static ${source_files})  #don't prepend "lib" set_target_properties(fileio properties prefix "") 

cdes cmakelists in scrubber/cdes

cmake_minimum_required(version 3.2) project(cdes)  set(cmake_cxx_flags "${cmake_cxx_flags} -std=c++11")  set(boost_include_dir "/usr/lib/boost_1_60_0")  include_directories( ${boost_include_dir} )  file(glob source_files *.cpp)  add_library(cdes static ${source_files})  #don't prepend "lib" set_target_properties(cdes properties prefix "") 

utilities cmakelist in scrubber/utilities

cmake_minimum_required(version 3.2) project(utilities)  set(cmake_cxx_flags "${cmake_cxx_flags} -std=c++11")  set(boost_include_dir "/usr/lib/boost_1_60_0")  include_directories( ${boost_include_dir} )  file(glob source_files *.cpp)  add_library(utilities static ${source_files})  #don't prepend "lib" set_target_properties(utilities properties prefix "") 

scrubber cmakelist in scrubber/scrubber

cmake_minimum_required(version 3.2) project(scrubber)  set(cmake_cxx_flags "${cmake_cxx_flags} -std=c++11")  set(boost_include_dir "/usr/lib/boost_1_60_0") set(project_include_dir "..")  include_directories(${boost_include_dir} ${project_include_dir})  find_library(fileio_lib fileio.a hints ../fileio/) find_library(cdes_lib cdes.a hints ../cdes/) find_library(utilities_lib utilities.a hints ../utilities/)  file(glob source_files *.cpp)  add_executable(scrubber ${source_files})  target_link_libraries(scrubber ${fileio_lib} ${cdes_lib} ${utilities_lib}) 

this wrong:

target_link_libraries(scrubber ${fileio_lib} ${cdes_lib} ${utilities_lib}) 

if have library add_library(fileio static ${source_files}), should write:

target_link_libraries(scrubber fileio ) 

cmake find out target, , create make file proper dependencies, , not have point dependencies add_dependency, cmake automatically. @ least current me cmake version 3.5


Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -