Created
July 30, 2014 18:21
-
-
Save SergNikitin/d8d9441120d00459201d to your computer and use it in GitHub Desktop.
building sdl_image as CMake external project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 2.8) | |
include(ExternalProject) | |
project(freetype_test) | |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall") | |
set(LIBS_DIR ${PROJECT_SOURCE_DIR}/libs) | |
set(FREETYPE_VER "2.5.3") | |
set(SDL2_VER "2.0.3") | |
# Freetype library | |
ExternalProject_Add(freetype_project | |
URL http://download.savannah.gnu.org/releases/freetype/freetype-${FREETYPE_VER}.tar.gz | |
PREFIX ${LIBS_DIR}/freetype | |
INSTALL_COMMAND "" | |
) | |
ExternalProject_Get_Property(freetype_project SOURCE_DIR) | |
ExternalProject_Get_Property(freetype_project BINARY_DIR) | |
set(FREETYPE_SRC ${SOURCE_DIR}) | |
set(FREETYPE_BIN ${BINARY_DIR}) | |
# SDL library | |
ExternalProject_Add(sdl2_project | |
URL http://www.libsdl.org/release/SDL2-${SDL2_VER}.tar.gz | |
PREFIX ${LIBS_DIR}/SDL2 | |
INSTALL_COMMAND "" | |
) | |
ExternalProject_Get_Property(sdl2_project SOURCE_DIR) | |
ExternalProject_Get_Property(sdl2_project BINARY_DIR) | |
set(SDL2_SRC ${SOURCE_DIR}) | |
set(SDL2_BIN ${BINARY_DIR}) | |
# SDL_image library | |
ExternalProject_Add(sdl2_image_project | |
URL https://www.libsdl.org/projects/SDL_image/release/SDL2_image-2.0.0.tar.gz | |
DEPENDS sdl2_project | |
PREFIX ${LIBS_DIR}/SDL2_image | |
CONFIGURE_COMMAND LDFLAGS=-L${SDL2_BIN} CFLAGS=-I${SDL2_SRC}/include SDL2_CONFIG=${SDL2_BIN}/sdl2-config <SOURCE_DIR>/configure --prefix=<INSTALL_DIR> --enable-shared=no | |
BUILD_COMMAND make | |
INSTALL_COMMAND "" | |
) | |
ExternalProject_Get_Property(sdl2_image_project SOURCE_DIR) | |
ExternalProject_Get_Property(sdl2_image_project BINARY_DIR) | |
set(SDL2_IMAGE_SRC ${SOURCE_DIR}) | |
set(SDL2_IMAGE_BIN ${BINARY_DIR}) | |
include_directories(${FREETYPE_SRC}/include) | |
include_directories(${SDL2_SRC}/include) | |
include_directories(${SDL2_IMAGE_SRC}/include) | |
set(SOURCE freetype_test.cpp) | |
add_executable(ft_test ${SOURCE}) | |
add_dependencies(ft_test freetype_project | |
sdl2_project | |
sdl2_image_project) | |
target_link_libraries(ft_test ${FREETYPE_BIN}/libfreetype.a | |
${SDL2_BIN}/libSDL2.a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Would you just run this as
cmake .
from the same folder as the.cmake
file?