0

I have totally 5 targets. one of them is static library. other 4 are executables. I don't want the library to be build for every time. so i just want to compile the library keep it in a particular location so that other executables can refer this library. i understood that we can do this by using install command.

But if i use install command, it is compiling all the targets. how to only compile one target and intall it into a location ?

add_compile_definitions(CMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY true)
install(TARGETS mylib DESTINATION lib)
  • not really clear what you are trying to achieve: if you want to make your library extrenal to your project, installing it won't be enough as the insternal deps remains on the local build. – OznOg Apr 10 '21 at 12:21

1 Answers1

0

it works by changing the command as below

set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY true)
install(TARGETS mylib DESTINATION lib)