I have a custom target, which is actually a library created externally that I want to integrate into my assembly.
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 I tell cmake that this target is actually a library , where it can be found, and where the headers are ?
To be clear: I do not want the top CMakeList, using this library, to manually specify the incoming folders and the library location folder . This should be done automatically (from the target properties).
In the standard cmake library, I just need to add the INTERFACE_INCLUDE_DIRECTORIES property to the CMakeLists library to force cmake to link my application with the corresponding -I and -L gcc parameters:
set_target_properties(lib1 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR})
But in the case of a custom goal, I donβt know how to go about it.
Any clue?
Thank you for your help.
Thanks zaufi it works!
For others who may be interested in a built-in external target implementation inside cmake, here is what I 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)
Now in CMakeLists.txt I can do something 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 to indicate where .a and .h are located.
source share