
file(READ ${CMAKE_SOURCE_DIR}/curses.h _CURSES_H_CONTENTS)

string(REGEX MATCH "#define PDC_VER_MAJOR    ([a-zA-Z0-9_]+)" PDC_VER_MAJOR "${_CURSES_H_CONTENTS}")
string(REPLACE "#define PDC_VER_MAJOR    " "" PDC_VER_MAJOR "${PDC_VER_MAJOR}")

string(REGEX MATCH "#define PDC_VER_MINOR    ([a-zA-Z0-9_]+)" PDC_VER_MINOR "${_CURSES_H_CONTENTS}")
string(REPLACE "#define PDC_VER_MINOR    " "" PDC_VER_MINOR "${PDC_VER_MINOR}")

string(REGEX MATCH "#define PDC_VER_CHANGE   ([a-zA-Z0-9_]+)" PDC_VER_CHANGE "${_CURSES_H_CONTENTS}")
string(REPLACE "#define PDC_VER_CHANGE   " "" PDC_VER_CHANGE "${PDC_VER_CHANGE}")

if(BUILD_NUMBER)
    set(CURSES_VERSION ${PDC_VER_MAJOR}.${PDC_VER_MINOR}.${PDC_VER_CHANGE}.${BUILD_NUMBER})
else()    
    set(CURSES_VERSION ${PDC_VER_MAJOR}.${PDC_VER_MINOR}.${PDC_VER_CHANGE}.0)
endif()
