Don't install when building as a static subdirectory
This is making lokimq headers & static lib get installed when lokimq is
used as a project subdirectory, which is very annoying.
This adds an option for enabling the install lines, and only enables it
if doing a shared library or a top-level project build.
option(BUILD_SHARED_LIBS"Build shared libraries instead of static ones"ON)
if(CMAKE_PROJECT_NAMESTREQUALPROJECT_NAME)
set(lokimq_IS_TOPLEVEL_PROJECTTRUE)
else()
set(lokimq_IS_TOPLEVEL_PROJECTFALSE)
endif()
option(BUILD_SHARED_LIBS"Build shared libraries instead of static ones"ON)
set(lokimq_INSTALL_DEFAULTOFF)
if(BUILD_SHARED_LIBSORlokimq_IS_TOPLEVEL_PROJECT)
set(lokimq_INSTALL_DEFAULTON)
endif()
option(LOKIMQ_BUILD_TESTS"Building and perform lokimq tests"${lokimq_IS_TOPLEVEL_PROJECT})
option(LOKIMQ_INSTALL"Add lokimq libraries and headers to cmake install target; defaults to ON if BUILD_SHARED_LIBS is enabled or we are the top-level project; OFF for a static subdirectory build"${lokimq_INSTALL_DEFAULT})
option(LOKIMQ_INSTALL_CPPZMQ"Install cppzmq header with lokimq/ headers (requires LOKIMQ_INSTALL)"ON)