i started following directory structure:
project exec executable.exe lib src include config <cmake-generated config file>
i created library in lib/src
folder using cmakefile in lib/src
folder. exe compile.
then, moved cmakefile /lib
, making sure change source file paths /src/*
now, when try compile, libraries compile , link fine, when try link executable, /usr/bin/ld: cannot find -lconfig
.
does have idea why happens or how fix it?
here of code:
./cmakelists.txt: include_directories(config) set(executable_output_path ${project_binary_dir}/bin) set(library_output_path ${project_binary_dir}/lib) add_subdirectory(libs) #library sources add_subdirectory(exec) #executable sources configure_file(${core_source_dir}/config/config.h.in ${core_source_dir}/config/config.h) ./libs/cmakelists.txt: file(glob src ...) file(glob header ...) add_library(lib ${src} ${header}) ./exec/cmakelists: add_executable(executable executable.cpp) link_directories(${core_source_dir}/lib) #not sure if required target_link_libraries(executable ${lots_of_libs})
every library in lots_of_libs
can found .a
file in lib
directory
one problem, not risolutive, this:
link_directories(${core_source_dir}/lib) #not sure if required
should be:
link_directories(${project_binary_dir}/lib)
or:
link_directories(${library_output_path})
anyway, wouldn't need add link_directories path library built within project, if have specified different library_output_path
Comments
Post a Comment