Skip to content

Commit

Permalink
Fixed cmake. Again.
Browse files Browse the repository at this point in the history
  • Loading branch information
inniyah committed Aug 3, 2020
1 parent 93c0a56 commit fc2fc5e
Showing 1 changed file with 59 additions and 57 deletions.
116 changes: 59 additions & 57 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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})
Expand Down Expand Up @@ -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_OBJECTS:nanovg> $<TARGET_OBJECTS:nanovg_gl2>)
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_OBJECTS:nanovg> $<TARGET_OBJECTS:nanovg_gl2>)
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_OBJECTS:nanovg> $<TARGET_OBJECTS:nanovg_gl3>)
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_OBJECTS:nanovg> $<TARGET_OBJECTS:nanovg_gl3>)
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_OBJECTS:nanovg> $<TARGET_OBJECTS:nanovg_gl3>)
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_OBJECTS:nanovg> $<TARGET_OBJECTS:nanovg_gl3>)
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_OBJECTS:nanovg> $<TARGET_OBJECTS:nanovg_gles2>)
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_OBJECTS:nanovg> $<TARGET_OBJECTS:nanovg_gles2>)
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_OBJECTS:nanovg> $<TARGET_OBJECTS:nanovg_gles3>)
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_OBJECTS:nanovg> $<TARGET_OBJECTS:nanovg_gles3>)
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 $<TARGET_OBJECTS:nanovg>)
Expand All @@ -181,16 +183,16 @@ ADD_EXECUTABLE(example_svg2 example/example_svg2.c $<TARGET_OBJECTS:nanovg>)
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_OBJECTS:nanovg> $<TARGET_OBJECTS:nanovg_gl3> $<TARGET_OBJECTS:nanovg_oui>)
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_OBJECTS:nanovg> $<TARGET_OBJECTS:nanovg_gl3> $<TARGET_OBJECTS:nanovg_oui>)
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_OBJECTS:nanovg>)
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_OBJECTS:nanovg>)
TARGET_LINK_LIBRARIES(example_gl_wrapper PRIVATE ${NANOVG_LIB_NAMES} GLEW EGL GL glfw m)
ENDIF()

ENDIF()

0 comments on commit fc2fc5e

Please sign in to comment.