diff --git a/CMakeLists.txt b/CMakeLists.txt index 6497d17..4e6738b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,8 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src) ADD_COMPILE_OPTIONS(-Wall -Werror) ADD_LINK_OPTIONS(LINKER:--as-needed LINKER:--no-undefined LINKER:--no-allow-shlib-undefined) +option(NANOVG_SHARED_LIBS "Build shared libraries" ON) +option(NANOVG_STATIC_LIBS "Build static liraries" ON) option(NANOVG_BUILD_EXAMPLES "Build examples" ON) option(NANOVG_BUILD_GL2 "Build OpenGL 2" ON) option(NANOVG_BUILD_GL3 "Build OpenGL 2" ON) @@ -106,26 +108,36 @@ ENDIF() SET(NANOVG_DEPENDENCIES EGL ${NANOVG_DEPENDENCIES}) -ADD_LIBRARY(nanovg_so SHARED ${NANOVG_LIB_OBJECTS}) +CONFIGURE_FILE(pkgconfig/nanovg.pc.in nanovg.pc @ONLY) -SET_TARGET_PROPERTIES(nanovg_so PROPERTIES VERSION ${VERSION} SOVERSION 0) -SET_TARGET_PROPERTIES(nanovg_so PROPERTIES OUTPUT_NAME nanovg) -TARGET_LINK_LIBRARIES(nanovg_so PUBLIC ${NANOVG_LIB_NAMES}) -TARGET_LINK_LIBRARIES(nanovg_so PRIVATE ${NANOVG_DEPENDENCIES}) +IF(NANOVG_SHARED_LIBS) + ADD_LIBRARY(nanovg_so SHARED ${NANOVG_LIB_OBJECTS}) -ADD_LIBRARY(nanovg_a STATIC ${NANOVG_LIB_OBJECTS}) + SET_TARGET_PROPERTIES(nanovg_so PROPERTIES VERSION ${VERSION} SOVERSION 0) + SET_TARGET_PROPERTIES(nanovg_so PROPERTIES OUTPUT_NAME nanovg) + TARGET_LINK_LIBRARIES(nanovg_so PUBLIC ${NANOVG_LIB_NAMES}) + TARGET_LINK_LIBRARIES(nanovg_so PRIVATE ${NANOVG_DEPENDENCIES}) -SET_TARGET_PROPERTIES(nanovg_a PROPERTIES OUTPUT_NAME nanovg) -TARGET_LINK_LIBRARIES(nanovg_a PUBLIC ${NANOVG_LIB_NAMES}) -TARGET_LINK_LIBRARIES(nanovg_a PRIVATE ${NANOVG_DEPENDENCIES}) + INSTALL(TARGETS nanovg_so + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION bin) +ENDIF() -CONFIGURE_FILE(pkgconfig/nanovg.pc.in nanovg.pc @ONLY) +IF(NANOVG_STATIC_LIBS) + ADD_LIBRARY(nanovg_a STATIC ${NANOVG_LIB_OBJECTS}) -INSTALL(TARGETS nanovg_so nanovg_a - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION bin) + SET_TARGET_PROPERTIES(nanovg_a PROPERTIES OUTPUT_NAME nanovg) + TARGET_LINK_LIBRARIES(nanovg_a PUBLIC ${NANOVG_LIB_NAMES}) + TARGET_LINK_LIBRARIES(nanovg_a PRIVATE ${NANOVG_DEPENDENCIES}) + + INSTALL(TARGETS nanovg_a + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION bin) +ENDIF() +# Install header files INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/src/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nanovg FILES_MATCHING PATTERN "nano*.h*")