From 7da7e483a37912d0cd2d276f81e2291a553213b4 Mon Sep 17 00:00:00 2001 From: anyc Date: Sat, 24 May 2014 13:22:01 +0200 Subject: [PATCH] added .travis.yml and modified CMake scripts --- .travis.yml | 39 +++++++++++++++++++++++++++------------ CMakeLists.txt | 26 ++++++++++++++------------ CMakeLists_mingw.txt | 10 ++++------ 3 files changed, 45 insertions(+), 30 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2685289d40..fae0c47d0f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,18 +1,33 @@ language: c + before_install: - - echo "yes" | sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu `lsb_release -sc` main universe restricted multiverse" - - echo "yes" | sudo apt-add-repository ppa:openmw/deps - - sudo apt-key update -qq - sudo apt-get update -qq - - sudo apt-get install -y --force-yes binutils-mingw-w64-i686 gcc-mingw-w64-i686 g++-mingw-w64-i686 libsdl2-static-dev libc6-dev-i386 - - ls -al /usr/bin - - ls -al /usr/include/SDL2 - - sudo mv /usr/include/SDL2 /usr/include/sdl2 + - sudo apt-get install -y --force-yes binutils-mingw-w64-i686 gcc-mingw-w64-i686 g++-mingw-w64-i686 + + # fetch precompiled SDL2 + headers for MinGW and push it into the expected directory + - export SDL2_PV=2.0.3 + - wget http://libsdl.org/release/SDL2-devel-${SDL2_PV}-mingw.tar.gz + - tar -xzvf SDL2-devel-${SDL2_PV}-mingw.tar.gz + + # but first fix SDL2 bug + - wget "https://github.com/anyc/anyc-overlay/raw/master/media-libs/libsdl2-mingw/files/libsdl2-mingw-2.0.3-fix-platform-detection-for-mingw.patch" + - pushd SDL2-${SDL2_PV}/i686-w64-mingw32/include/SDL2/ && patch -p2 < ../../../../libsdl2-mingw-2.0.3-fix-platform-detection-for-mingw.patch && popd + + - sudo mkdir -p /usr/local/cross-tools/ + - sudo mv SDL2-${SDL2_PV}/i686-w64-mingw32 /usr/local/cross-tools/ + + # build a wrapper that looks for the sdl2.pc file in the new directory + - echo -e "#! /bin/sh\\nexport PKG_CONFIG_LIBDIR=/usr/local/cross-tools/i686-w64-mingw32/lib/pkgconfig\\npkg-config \$@" > i686-w64-mingw32-pkg-config + - chmod +x i686-w64-mingw32-pkg-config + - sudo mv i686-w64-mingw32-pkg-config /usr/local/bin/ + script: - - sudo find / -name SDL2 2>>/dev/null || true - mkdir build - - pushd build && cmake -DCMAKE_TOOLCHAIN_FILE=../CMakeLists_mingw.txt -DCMAKE_BUILD_TYPE=Debug .. && popd - - sudo find / -name stubs-32.h 2>>/dev/null || true - - pushd build && C_INCLUDE_PATH=/usr/include/x86_64-linux-gnu/bits:/usr/include/sdl2:$C_INCLUDE_PATH make && popd + - pushd build + - cmake -DCMAKE_TOOLCHAIN_FILE=../CMakeLists_mingw.txt -DCMAKE_BUILD_TYPE=Debug .. + - make + #- make VERBOSE=1 + - popd + #notifications: - #irc: "irc.freenode.net#openrct2" + #irc: "irc.freenode.net#openrct2" \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ac432ad6a..5c911bb9fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,31 +25,33 @@ project(${PROJECT}) add_definitions(-DORCT2_RESOURCE_DIR="${ORCT2_RESOURCE_DIR}") -# include lodepng +# include lodepng header include_directories("lodepng/") +# add source files file(GLOB_RECURSE ORCT2_SOURCES "src/*.c" "lodepng/*.c") -# build as library for now, replace with add_executable -add_library(${PROJECT} SHARED ${ORCT2_SOURCES}) - -# install into ${CMAKE_INSTALL_PREFIX}/bin/ -install (TARGETS ${PROJECT} DESTINATION bin) - -# libopenrct2.dll -> openrct2.dll -set_target_properties(${PROJECT} PROPERTIES PREFIX "") - if (UNIX) # force 32bit build for now and set necessary flags to compile code as is - set(CMAKE_C_FLAGS "-m32 -masm=intel -std=c99") + set(CMAKE_C_FLAGS "-m32 -masm=intel -std=gnu99") set(CMAKE_LDFLAGS_FLAGS "-m32") # find and include SDL2 INCLUDE(FindPkgConfig) PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2) INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIRS}) - TARGET_LINK_LIBRARIES(${PROJECT} ${SDL2_LIBRARIES}) endif (UNIX) +LINK_DIRECTORIES(${SDL2_LIBRARY_DIRS}) + +# build as library for now, replace with add_executable +add_library(${PROJECT} SHARED ${ORCT2_SOURCES}) + +# install into ${CMAKE_INSTALL_PREFIX}/bin/ +#install (TARGETS ${PROJECT} DESTINATION bin) + +# libopenrct2.dll -> openrct2.dll +set_target_properties(${PROJECT} PROPERTIES PREFIX "") + TARGET_LINK_LIBRARIES(${PROJECT} ${SDL2_LIBRARIES}) if (WIN32) diff --git a/CMakeLists_mingw.txt b/CMakeLists_mingw.txt index 1f92220945..a891576ae6 100644 --- a/CMakeLists_mingw.txt +++ b/CMakeLists_mingw.txt @@ -16,14 +16,12 @@ set(CMAKE_SHARED_LINKER_FLAGS "-static-libgcc" CACHE STRING "" FORCE) include_directories("/usr/include/wine/windows/") # find and include SDL2 -# INCLUDE(FindPkgConfig) -# PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2) -INCLUDE_DIRECTORIES("/usr/include") -INCLUDE_DIRECTORIES("/usr/include/x86_64-linux-gnu") -INCLUDE_DIRECTORIES("/usr/include/sdl2") +INCLUDE(FindPkgConfig) +PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2) +INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIRS}) # here is the target environment located -SET(CMAKE_FIND_ROOT_PATH /usr/${COMPILER_PREFIX}) +#SET(CMAKE_FIND_ROOT_PATH /usr/${COMPILER_PREFIX}) # adjust the default behaviour of the FIND_XXX() commands: # search headers and libraries in the target environment, search