CMAKE_MINIMUM_REQUIRED( VERSION 3.0 )

PROJECT( FTGL )

SET( TARGET ftgl )

# Include some general purpuse macros and definitions.
SET( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMakeModules )

INCLUDE( Macros )
INCLUDE( Common )

# Define FTGL version number.
SET( FTGL_VERSION_MAJOR 2 )
SET( FTGL_VERSION_MINOR 1 )
SET( FTGL_VERSION_PATCH 3 )
SET( FTGL_VERSION ${FTGL_VERSION_MAJOR}.${FTGL_VERSION_MINOR}.${FTGL_VERSION_PATCH} )

# Find packages needed for all modules.
FIND_PACKAGE( Freetype REQUIRED )

FIND_SOURCES( SOURCES src src/FTFont src/FTGL src/FTGlyph src/FTLayout )
ADD_LIBRARY( ${TARGET} SHARED ${SOURCES} )

IF( MSVC )
    ADD_DEFINITIONS( "-DWIN32" )
    ADD_DEFINITIONS( "-D_WINDOWS" )
    ADD_DEFINITIONS( "-D_USRDLL" )
ENDIF()
ADD_DEFINITIONS( "-DFTGL_LIBRARY" )

SET( CMAKE_INCLUDE_CURRENT_DIR ON )
INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR} )
INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/src )
INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/src/FTGL )
INCLUDE_DIRECTORIES( ${FREETYPE_INCLUDE_DIR_freetype2} )
INCLUDE_DIRECTORIES( ${FREETYPE_INCLUDE_DIR_ft2build} )
INCLUDE_DIRECTORIES( ${FREETYPE_INCLUDE_DIR_ft2build}/.. )

TARGET_LINK_LIBRARIES( ${TARGET} ${FREETYPE_LIBRARY} ${SYS_LIBS} )

INSTALL( TARGETS ${TARGET} DESTINATION bin )
