diff --git a/CMakeLists.txt b/CMakeLists.txt index 0719d07..6497d17 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ SET(NANOVG_OUI_DEFINES "") SET(NANOVG_OUI_SOURCES "src/oui.c" "src/blendish.c") IF(NANOVG_BUILD_GL2 OR NANOVG_BUILD_GL3) -LIST(APPEND NANOVG_GL_DEFINES NANOVG_USE_GLEW) + LIST(APPEND NANOVG_GL_DEFINES NANOVG_USE_GLEW) ENDIF() # Build Library @@ -35,38 +35,38 @@ TARGET_COMPILE_DEFINITIONS(nanovg PRIVATE ${NANOVG_DEFINES}) SET_PROPERTY(TARGET nanovg PROPERTY POSITION_INDEPENDENT_CODE ON) IF(NANOVG_BUILD_GL2) -ADD_LIBRARY(nanovg_gl2 OBJECT ${NANOVG_GL_SOURCES}) -TARGET_INCLUDE_DIRECTORIES(nanovg_gl2 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src) -TARGET_COMPILE_DEFINITIONS(nanovg_gl2 PRIVATE ${NANOVG_GL_DEFINES} NANOVG_GL2) -SET_PROPERTY(TARGET nanovg_gl2 PROPERTY POSITION_INDEPENDENT_CODE ON) + ADD_LIBRARY(nanovg_gl2 OBJECT ${NANOVG_GL_SOURCES}) + TARGET_INCLUDE_DIRECTORIES(nanovg_gl2 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src) + TARGET_COMPILE_DEFINITIONS(nanovg_gl2 PRIVATE ${NANOVG_GL_DEFINES} NANOVG_GL2) + SET_PROPERTY(TARGET nanovg_gl2 PROPERTY POSITION_INDEPENDENT_CODE ON) ENDIF() IF(NANOVG_BUILD_GL3) -ADD_LIBRARY(nanovg_gl3 OBJECT ${NANOVG_GL_SOURCES}) -TARGET_INCLUDE_DIRECTORIES(nanovg_gl3 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src) -TARGET_COMPILE_DEFINITIONS(nanovg_gl3 PRIVATE ${NANOVG_GL_DEFINES} NANOVG_GL3) -SET_PROPERTY(TARGET nanovg_gl3 PROPERTY POSITION_INDEPENDENT_CODE ON) + ADD_LIBRARY(nanovg_gl3 OBJECT ${NANOVG_GL_SOURCES}) + TARGET_INCLUDE_DIRECTORIES(nanovg_gl3 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src) + TARGET_COMPILE_DEFINITIONS(nanovg_gl3 PRIVATE ${NANOVG_GL_DEFINES} NANOVG_GL3) + SET_PROPERTY(TARGET nanovg_gl3 PROPERTY POSITION_INDEPENDENT_CODE ON) ENDIF() IF(NANOVG_BUILD_GLES2) -ADD_LIBRARY(nanovg_gles2 OBJECT ${NANOVG_GLES_SOURCES}) -TARGET_INCLUDE_DIRECTORIES(nanovg_gles2 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src) -TARGET_COMPILE_DEFINITIONS(nanovg_gles2 PRIVATE NANOVG_GLES2) -SET_PROPERTY(TARGET nanovg_gles2 PROPERTY POSITION_INDEPENDENT_CODE ON) + ADD_LIBRARY(nanovg_gles2 OBJECT ${NANOVG_GLES_SOURCES}) + TARGET_INCLUDE_DIRECTORIES(nanovg_gles2 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src) + TARGET_COMPILE_DEFINITIONS(nanovg_gles2 PRIVATE NANOVG_GLES2) + SET_PROPERTY(TARGET nanovg_gles2 PROPERTY POSITION_INDEPENDENT_CODE ON) ENDIF() IF(NANOVG_BUILD_GLES3) -ADD_LIBRARY(nanovg_gles3 OBJECT ${NANOVG_GLES_SOURCES}) -TARGET_INCLUDE_DIRECTORIES(nanovg_gles3 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src) -TARGET_COMPILE_DEFINITIONS(nanovg_gles3 PRIVATE NANOVG_GLES3) -SET_PROPERTY(TARGET nanovg_gles3 PROPERTY POSITION_INDEPENDENT_CODE ON) + ADD_LIBRARY(nanovg_gles3 OBJECT ${NANOVG_GLES_SOURCES}) + TARGET_INCLUDE_DIRECTORIES(nanovg_gles3 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src) + TARGET_COMPILE_DEFINITIONS(nanovg_gles3 PRIVATE NANOVG_GLES3) + SET_PROPERTY(TARGET nanovg_gles3 PROPERTY POSITION_INDEPENDENT_CODE ON) ENDIF() IF(NANOVG_BUILD_OUI) -ADD_LIBRARY(nanovg_oui OBJECT ${NANOVG_OUI_SOURCES}) -TARGET_INCLUDE_DIRECTORIES(nanovg_oui PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src) -TARGET_COMPILE_DEFINITIONS(nanovg_oui PRIVATE ${NANOVG_OUI_DEFINES}) -SET_PROPERTY(TARGET nanovg_oui PROPERTY POSITION_INDEPENDENT_CODE ON) + ADD_LIBRARY(nanovg_oui OBJECT ${NANOVG_OUI_SOURCES}) + TARGET_INCLUDE_DIRECTORIES(nanovg_oui PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src) + TARGET_COMPILE_DEFINITIONS(nanovg_oui PRIVATE ${NANOVG_OUI_DEFINES}) + SET_PROPERTY(TARGET nanovg_oui PROPERTY POSITION_INDEPENDENT_CODE ON) ENDIF() SET(NANOVG_LIB_NAMES nanovg) @@ -95,13 +95,15 @@ ENDIF() SET(NANOVG_DEPENDENCIES m) IF(NANOVG_BUILD_GL2 OR NANOVG_BUILD_GL3) SET(NANOVG_DEPENDENCIES GLEW GL ${NANOVG_DEPENDENCIES}) +ELSE() + IF(NANOVG_BUILD_GLES2) + SET(NANOVG_DEPENDENCIES GLESv2 ${NANOVG_DEPENDENCIES}) + ENDIF() + IF(NANOVG_BUILD_GLES2) + SET(NANOVG_DEPENDENCIES GLESv3 ${NANOVG_DEPENDENCIES}) + ENDIF() ENDIF() -IF(NANOVG_BUILD_GLES2) - SET(NANOVG_DEPENDENCIES GLESv2 ${NANOVG_DEPENDENCIES}) -ENDIF() -IF(NANOVG_BUILD_GLES2) - SET(NANOVG_DEPENDENCIES GLESv3 ${NANOVG_DEPENDENCIES}) -ENDIF() + SET(NANOVG_DEPENDENCIES EGL ${NANOVG_DEPENDENCIES}) ADD_LIBRARY(nanovg_so SHARED ${NANOVG_LIB_OBJECTS}) @@ -137,41 +139,41 @@ INSTALL(FILES ${CMAKE_BINARY_DIR}/nanovg.pc IF(NANOVG_BUILD_EXAMPLES) IF(NANOVG_BUILD_GL2) -ADD_EXECUTABLE(example_gl2 - example/example_gl2.c example/demo.c example/perf.c - $ $) -TARGET_LINK_LIBRARIES(example_gl2 PRIVATE nanovg nanovg_gl2 GLEW EGL GL glfw m) -TARGET_COMPILE_DEFINITIONS(example_gl2 PRIVATE ${NANOVG_GL_DEFINES} NANOVG_GL2) + ADD_EXECUTABLE(example_gl2 + example/example_gl2.c example/demo.c example/perf.c + $ $) + TARGET_LINK_LIBRARIES(example_gl2 PRIVATE nanovg nanovg_gl2 GLEW EGL GL glfw m) + TARGET_COMPILE_DEFINITIONS(example_gl2 PRIVATE ${NANOVG_GL_DEFINES} NANOVG_GL2) ENDIF() IF(NANOVG_BUILD_GL3) -ADD_EXECUTABLE(example_gl3 - example/example_gl3.c example/demo.c example/perf.c - $ $) -TARGET_LINK_LIBRARIES(example_gl3 PRIVATE nanovg nanovg_gl3 GLEW EGL GL glfw m) -TARGET_COMPILE_DEFINITIONS(example_gl3 PRIVATE ${NANOVG_GL_DEFINES} NANOVG_GL3) + ADD_EXECUTABLE(example_gl3 + example/example_gl3.c example/demo.c example/perf.c + $ $) + TARGET_LINK_LIBRARIES(example_gl3 PRIVATE nanovg nanovg_gl3 GLEW EGL GL glfw m) + TARGET_COMPILE_DEFINITIONS(example_gl3 PRIVATE ${NANOVG_GL_DEFINES} NANOVG_GL3) ENDIF() IF(NANOVG_BUILD_GL3) -ADD_EXECUTABLE(example_fbo example/example_fbo.c example/demo.c example/perf.c $ $) -TARGET_LINK_LIBRARIES(example_fbo PRIVATE nanovg_gl3 GLEW EGL GL glfw m) -TARGET_COMPILE_DEFINITIONS(example_fbo PRIVATE ${NANOVG_GL_DEFINES} NANOVG_GL3) + ADD_EXECUTABLE(example_fbo example/example_fbo.c example/demo.c example/perf.c $ $) + TARGET_LINK_LIBRARIES(example_fbo PRIVATE nanovg_gl3 GLEW EGL GL glfw m) + TARGET_COMPILE_DEFINITIONS(example_fbo PRIVATE ${NANOVG_GL_DEFINES} NANOVG_GL3) ENDIF() IF(NANOVG_BUILD_GLES2) -ADD_EXECUTABLE(example_gles2 - example/example_gles2.c example/demo.c example/perf.c - $ $) -TARGET_LINK_LIBRARIES(example_gles2 PRIVATE GLEW EGL GL glfw m) -TARGET_COMPILE_DEFINITIONS(example_gles2 PRIVATE NANOVG_GLES2) + ADD_EXECUTABLE(example_gles2 + example/example_gles2.c example/demo.c example/perf.c + $ $) + TARGET_LINK_LIBRARIES(example_gles2 PRIVATE GLEW EGL GL glfw m) + TARGET_COMPILE_DEFINITIONS(example_gles2 PRIVATE NANOVG_GLES2) ENDIF() IF(NANOVG_BUILD_GLES3) -ADD_EXECUTABLE(example_gles3 - example/example_gles3.c example/demo.c example/perf.c - $ $) -TARGET_LINK_LIBRARIES(example_gles3 PRIVATE GLEW EGL GL glfw m) -TARGET_COMPILE_DEFINITIONS(example_gles3 PRIVATE NANOVG_GLES3) + ADD_EXECUTABLE(example_gles3 + example/example_gles3.c example/demo.c example/perf.c + $ $) + TARGET_LINK_LIBRARIES(example_gles3 PRIVATE GLEW EGL GL glfw m) + TARGET_COMPILE_DEFINITIONS(example_gles3 PRIVATE NANOVG_GLES3) ENDIF() ADD_EXECUTABLE(example_svg1 example/example_svg1.c $) @@ -181,16 +183,16 @@ ADD_EXECUTABLE(example_svg2 example/example_svg2.c $) TARGET_LINK_LIBRARIES(example_svg2 PRIVATE GLEW EGL GL glfw m) IF(NANOVG_BUILD_GL3 AND NANOVG_BUILD_OUI) -ADD_EXECUTABLE(example_oui - example/example_oui.c - $ $ $) -TARGET_LINK_LIBRARIES(example_oui PRIVATE GLEW EGL GL glfw m) -TARGET_COMPILE_DEFINITIONS(example_oui PRIVATE DATADIR="../data") + ADD_EXECUTABLE(example_oui + example/example_oui.c + $ $ $) + TARGET_LINK_LIBRARIES(example_oui PRIVATE GLEW EGL GL glfw m) + TARGET_COMPILE_DEFINITIONS(example_oui PRIVATE DATADIR="../data") ENDIF() IF(NANOVG_BUILD_GL2 AND NANOVG_BUILD_GL3 AND NANOVG_BUILD_GLES2 AND NANOVG_BUILD_GLES3) -ADD_EXECUTABLE(example_gl_wrapper example/example_gl_wrapper example/demo.c $) -TARGET_LINK_LIBRARIES(example_gl_wrapper PRIVATE ${NANOVG_LIB_NAMES} GLEW EGL GL glfw m) + ADD_EXECUTABLE(example_gl_wrapper example/example_gl_wrapper example/demo.c $) + TARGET_LINK_LIBRARIES(example_gl_wrapper PRIVATE ${NANOVG_LIB_NAMES} GLEW EGL GL glfw m) ENDIF() ENDIF()