libsuperderpy/cmake/libsuperderpy.cmake

81 lines
2.9 KiB
CMake
Raw Normal View History

2016-07-03 20:34:31 +02:00
if (NOT LIBSUPERDERPY_CONFIG_INCLUDED)
2016-07-02 23:23:08 +02:00
add_definitions(-D_XOPEN_SOURCE=600)
2016-07-03 00:43:32 +02:00
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -std=c11")
2016-07-02 23:23:08 +02:00
if(APPLE)
2016-07-03 00:43:32 +02:00
if(CMAKE_INSTALL_PREFIX MATCHES "/usr/local")
2016-07-05 01:30:06 +02:00
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}")
2016-07-03 00:43:32 +02:00
set(BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}")
2016-07-05 01:30:06 +02:00
set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${LIBSUPERDERPY_GAMENAME}.app/Contents/MacOS/")
2016-07-03 00:43:32 +02:00
endif(CMAKE_INSTALL_PREFIX MATCHES "/usr/local")
2016-07-05 01:30:06 +02:00
set(MACOSX_BUNDLE_ICON_FILE ${LIBSUPERDERPY_GAMENAME})
set(MACOSX_BUNDLE_BUNDLE_NAME ${LIBSUPERDERPY_GAMENAME_PRETTY})
2016-07-02 23:23:08 +02:00
endif(APPLE)
2016-07-03 20:34:31 +02:00
include_directories("libsuperderpy/src")
2016-07-02 23:23:08 +02:00
if(MINGW)
# Guess MINGDIR from the value of CMAKE_C_COMPILER if it's not set.
2016-07-03 20:34:31 +02:00
if(NOT MINGDIR)
if("$ENV{MINGDIR}" STREQUAL "")
string(REGEX REPLACE "/bin/[^/]*$" "" MINGDIR "${CMAKE_C_COMPILER}")
message(STATUS "Guessed MinGW directory: ${MINGDIR}")
else("$ENV{MINGDIR}" STREQUAL "")
file(TO_CMAKE_PATH "$ENV{MINGDIR}" MINGDIR)
message(STATUS "Using MINGDIR: ${MINGDIR}")
endif("$ENV{MINGDIR}" STREQUAL "")
endif(NOT MINGDIR)
2016-07-02 23:23:08 +02:00
# Search in MINGDIR for headers and libraries.
set(CMAKE_PREFIX_PATH "${MINGDIR}")
endif(MINGW)
2016-07-03 00:43:32 +02:00
set(CMAKE_INSTALL_RPATH "\$ORIGIN/../lib/${LIBSUPERDERPY_GAMENAME}:\$ORIGIN/gamestates:\$ORIGIN:\$ORIGIN/../lib:\$ORIGIN/lib:\$ORIGIN/bin")
2016-07-02 23:23:08 +02:00
2016-07-03 20:34:31 +02:00
find_package(Allegro5 REQUIRED)
find_package(Allegro5Font REQUIRED)
find_package(Allegro5TTF REQUIRED)
find_package(Allegro5Primitives REQUIRED)
find_package(Allegro5Audio REQUIRED)
find_package(Allegro5ACodec REQUIRED)
find_package(Allegro5Image REQUIRED)
find_package(Allegro5Color REQUIRED)
if(APPLE)
find_package(Allegro5Main)
endif(APPLE)
2016-07-02 23:23:08 +02:00
2016-07-03 00:43:32 +02:00
MACRO(register_gamestate name)
2016-07-02 23:23:08 +02:00
add_library("libsuperderpy-${LIBSUPERDERPY_GAMENAME}-${name}" SHARED "${name}")
2016-07-02 23:23:08 +02:00
2016-07-03 00:43:32 +02:00
set_target_properties("libsuperderpy-${LIBSUPERDERPY_GAMENAME}-${name}" PROPERTIES PREFIX "")
2016-07-02 23:23:08 +02:00
2016-07-03 00:43:32 +02:00
target_link_libraries("libsuperderpy-${LIBSUPERDERPY_GAMENAME}-${name}" ${ALLEGRO5_LIBRARIES} ${ALLEGRO5_FONT_LIBRARIES} ${ALLEGRO5_TTF_LIBRARIES} ${ALLEGRO5_PRIMITIVES_LIBRARIES} ${ALLEGRO5_AUDIO_LIBRARIES} ${ALLEGRO5_ACODEC_LIBRARIES} ${ALLEGRO5_IMAGE_LIBRARIES} ${ALLEGRO5_COLOR_LIBRARIES} m libsuperderpy)
2016-07-02 23:23:08 +02:00
if (TARGET libsuperderpy-${LIBSUPERDERPY_GAMENAME})
target_link_libraries("libsuperderpy-${LIBSUPERDERPY_GAMENAME}-${name}" libsuperderpy-${LIBSUPERDERPY_GAMENAME})
ENDIF()
2016-07-03 00:43:32 +02:00
install(TARGETS "libsuperderpy-${LIBSUPERDERPY_GAMENAME}-${name}" DESTINATION ${LIB_INSTALL_DIR})
2016-07-02 23:23:08 +02:00
ENDMACRO()
MACRO(libsuperderpy_copy EXECUTABLE)
2016-07-05 01:30:06 +02:00
if (NOT APPLE)
add_custom_command(TARGET "${EXECUTABLE}" PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "../libsuperderpy/src/libsuperderpy${CMAKE_SHARED_LIBRARY_SUFFIX}" $<TARGET_FILE_DIR:${EXECUTABLE}>)
endif (NOT APPLE)
2016-07-02 23:23:08 +02:00
ENDMACRO()
include(InstallRequiredSystemLibraries)
2016-07-03 20:34:31 +02:00
set(LIBSUPERDERPY_CONFIG_INCLUDED 1)
endif (NOT LIBSUPERDERPY_CONFIG_INCLUDED)