custom target as a target library in cmake -
i have custom target in fact externally generated library want integrate in build.
add_custom_command( output ${cmake_current_binary_dir}/liblib2.a command make -f ${cmake_current_source_dir}/makefile liblib2.a) add_custom_target(lib2 depends ${cmake_current_binary_dir}/liblib2.a) how can tell cmake target in fact library, where can found , headers ?
to clear : i don't want upper cmakelist using library having manually specify include folders , library location folder must done automatically (from target properties).
on standard cmake library have add interface_include_directories property in library cmakelists make cmake link app relevant -i , -l gcc parameters :
set_target_properties(lib1 properties interface_include_directories ${cmake_current_source_dir}) but in case of custom target don't know how to it.
any clue ?
thanks help.
thanks zaufi works!
for others may interested in embedded externally build target inside cmake here did :
cmake_minimum_required(version 2.8) set(lib_file ${cmake_current_source_dir}/bin/liblib2.a) set(lib_header_folder ${cmake_current_source_dir}/include) # how build result of library add_custom_command(output ${lib_file} command make working_directory ${cmake_current_source_dir}) # create target out of library compilation result add_custom_target(lib2_target depends ${lib_file}) # create library target out of library compilation result add_library(lib2 static imported global) add_dependencies(lib2 lib2_target) # specify library , find headers set_target_properties(lib2 properties imported_location ${lib_file} interface_include_directories ${lib_header_folder}) now in cmakelists.txt can somthing like
add_subdirectory(${root_dir}/lib1 bin/lib1) add_subdirectory(${root_dir}/lib2 bin/lib2) add_executable(app app.c ) target_link_libraries(app lib1 lib2) no need specify .a , .h are.
you can use add_library() , tell imported. then, using set_target_properties() can set required interface_xxx properties it. after that, can use ordinal target every other built project.
Comments
Post a Comment