[CMAKE] Add Coin3D version info

Modelled after the code for Eigen3, this adds a version check for Coin.
If pkg_config (or some other method) finds the version string, just
print that. If not, do a REGEX MATCH on the file in Coin's headers that
includes the version information. Note that in this case the beta
version information is excluded.
This commit is contained in:
Chris Hennes
2021-02-10 23:58:22 -06:00
committed by wmayer
parent 4b4a6b3580
commit 0ed341a84c
2 changed files with 13 additions and 1 deletions

View File

@@ -105,5 +105,17 @@ ENDIF (WIN32)
IF(COIN3D_LIBRARIES)
SET( COIN3D_FOUND "YES" )
message(STATUS "Coin3D libraries found")
IF(NOT COIN3D_VERSION)
file(READ "${COIN3D_INCLUDE_DIRS}/Inventor/C/basic.h" _coin3d_basic_h)
string(REGEX MATCH "define[ \t]+COIN_MAJOR_VERSION[ \t]+([0-9?])" _coin3d_major_version_match "${_coin3d_basic_h}")
set(COIN3D_MAJOR_VERSION "${CMAKE_MATCH_1}")
string(REGEX MATCH "define[ \t]+COIN_MINOR_VERSION[ \t]+([0-9?])" _coin3d_minor_version_match "${_coin3d_basic_h}")
set(COIN3D_MINOR_VERSION "${CMAKE_MATCH_1}")
string(REGEX MATCH "define[ \t]+COIN_MICRO_VERSION[ \t]+([0-9?])" _coin3d_micro_version_match "${_coin3d_basic_h}")
set(COIN3D_MICRO_VERSION "${CMAKE_MATCH_1}")
set(COIN3D_VERSION "${COIN3D_MAJOR_VERSION}.${COIN3D_MINOR_VERSION}.${COIN3D_MICRO_VERSION}")
ENDIF()
ENDIF(COIN3D_LIBRARIES)

View File

@@ -166,7 +166,7 @@ macro(PrintFinalReport)
message(STATUS "OpenGL: ${OPENGL_gl_LIBRARY}")
message(STATUS "OpenGLU: ${OPENGL_glu_LIBRARY} [${OPENGL_glu_LIBRARY}][${OPENGL_INCLUDE_DIR}]")
message(STATUS "Coin3D: [${COIN3D_LIBRARIES}] [${COIN3D_INCLUDE_DIRS}]")
message(STATUS "Coin3D: ${COIN3D_VERSION} [${COIN3D_LIBRARIES}] [${COIN3D_INCLUDE_DIRS}]")
if (WIN32)