···25252626set(SDL_GPU_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUGFIX}")
27272828-message("Writing version header for v${SDL_GPU_VERSION}")
2929-string(CONCAT VERSION_HEADER_CONTENTS "#ifndef _SDL_GPU_VERSION_H__
2828+if(${CMAKE_CURRENT_SOURCE_DIR}/version.txt IS_NEWER_THAN ${CMAKE_CURRENT_SOURCE_DIR}/include/SDL_gpu_version.h)
2929+ # This is to prevent CMake from rebuilding SDL_gpu, which is important when it is an external project in another project.
3030+ # This works since whenever version.txt is changed, it will be newer than SDL_gpu_version.h. The only time SDL_gpu_version.h
3131+ # will be newer than version.txt is when it is created or modified after the latter file.
3232+ message("Writing version header for v${SDL_GPU_VERSION}")
3333+ string(CONCAT VERSION_HEADER_CONTENTS "#ifndef _SDL_GPU_VERSION_H__
3034#define _SDL_GPU_VERSION_H__
31353236#define SDL_GPU_VERSION_MAJOR ${VERSION_MAJOR}
···3438#define SDL_GPU_VERSION_PATCH ${VERSION_BUGFIX}
35393640#endif")
3737-file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/include/SDL_gpu_version.h ${VERSION_HEADER_CONTENTS})
4141+4242+ file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/include/SDL_gpu_version.h ${VERSION_HEADER_CONTENTS})
4343+endif()
38443945set(DEFAULT_INSTALL_LIBRARY ON)
4046set(DEFAULT_BUILD_SHARED ON)
···100106option(BUILD_TESTS "Build SDL_gpu test programs" OFF)
101107option(BUILD_VIDEO_TEST "Build SDL_gpu video test program (requires FFMPEG)" OFF)
102108option(BUILD_TOOLS "Build SDL_gpu tool programs" OFF)
109109+option(BUILD_DOCS "Build SDL_gpu documentation" OFF)
103110option(USE_SDL1 "Use SDL 1.2 headers and library instead of SDL 2" OFF)
104111option(DISABLE_OPENGL "Disable OpenGL renderers. Overrides specific OpenGL renderer flags." ${DEFAULT_DISABLE_OPENGL})
105112option(DISABLE_GLES "Disable OpenGLES renderers. Overrides specific GLES renderer flags." ${DEFAULT_DISABLE_GLES})
···323330endif(NOT STBI_FOUND OR NOT STBI_WRITE_FOUND)
324331325332# add a target to generate API documentation with Doxygen
326326-find_package(Doxygen)
327327-if(DOXYGEN_FOUND)
328328- set(DOXYGEN_INPUT ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src)
329329- configure_file(${CMAKE_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
330330- add_custom_target(doc
331331- ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
332332- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
333333- COMMENT "Generating API documentation with Doxygen" VERBATIM
334334- )
335335-endif(DOXYGEN_FOUND)
333333+if (BUILD_DOCS)
334334+ find_package(Doxygen)
335335+ if(DOXYGEN_FOUND)
336336+ set(DOXYGEN_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/src)
337337+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
338338+ add_custom_target(doc
339339+ ` ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
340340+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
341341+ COMMENT "Generating API documentation with Doxygen" VERBATIM
342342+ )
343343+ endif(DOXYGEN_FOUND)
344344+endif (BUILD_DOCS)
336345337346add_definitions("-Wall -pedantic")
338347