boost pthreads sdl: tidy up cmake tests

closes #887
This commit is contained in:
Tony Theodore 2015-10-04 16:01:18 +11:00
parent 1dd126b160
commit ee5db756fa
7 changed files with 79 additions and 29 deletions

14
src/boost-test.cmake Normal file
View File

@ -0,0 +1,14 @@
# This file is part of MXE.
# See index.html for further information.
# partial module - included by src/cmake/CMakeLists.txt
set(TGT test-${PKG}-cmake)
enable_language(CXX)
add_executable(${TGT} ${CMAKE_CURRENT_LIST_DIR}/${PKG}-test.cpp)
find_package(Boost ${PKG_VERSION} EXACT COMPONENTS chrono serialization system thread REQUIRED)
target_link_libraries(${TGT} ${Boost_LIBRARIES})
install(TARGETS ${TGT} DESTINATION bin)

View File

@ -74,14 +74,9 @@ define $(PKG)_BUILD
# test cmake
mkdir '$(1).test-cmake'
(echo 'cmake_minimum_required(VERSION 2.8.11)'; \
echo 'project(test-$(PKG)-cmake)'; \
echo 'find_package(Boost COMPONENTS chrono serialization system thread REQUIRED)'; \
echo 'add_executable(test-$(PKG)-cmake $(PREFIX)/../src/$(PKG)-test.cpp)'; \
echo 'target_link_libraries(test-$(PKG)-cmake $${Boost_LIBRARIES})'; \
echo 'install(TARGETS test-$(PKG)-cmake DESTINATION bin)'; \
) > '$(1).test-cmake/CMakeLists.txt'
cd '$(1).test-cmake' && '$(TARGET)-cmake' .
cd '$(1).test-cmake' && '$(TARGET)-cmake' \
-DPKG=$(PKG) \
-DPKG_VERSION=$($(PKG)_VERSION) \
'$(PWD)/src/cmake/test'
$(MAKE) -C '$(1).test-cmake' -j 1 install
endef

View File

@ -0,0 +1,18 @@
# This file is part of MXE.
# See index.html for further information.
# 2.8.11 is recommended as a minimum for Qt5
# http://doc.qt.io/qt-5/cmake-manual.html
cmake_minimum_required(VERSION 2.8.11)
# set languages in individual modules
project(mxe LANGUAGES NONE)
# see cmake --help-policy <cmp> for details
cmake_policy(SET CMP0017 NEW)
cmake_policy(SET CMP0020 NEW)
# so we can find pkg-test.cmake files to include
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../.. ${CMAKE_MODULE_PATH})
include(${PKG}-test)

View File

@ -25,17 +25,13 @@ define PTHREADS_TEST
'$(TARGET)-gcc' \
-W -Wall -Werror -ansi -pedantic \
'$(TOP_DIR)/src/pthreads-test.c' -o '$(PREFIX)/$(TARGET)/bin/test-pthreads.exe' \
'$(TOP_DIR)/src/pthreads-test.c' -o '$(PREFIX)/$(TARGET)/bin/test-$(PKG).exe' \
`'$(TARGET)-pkg-config' --libs pthreads`
# test cmake
mkdir '$(1).cmake'
(echo 'find_package(Threads REQUIRED)'; \
echo 'add_executable(test-pthreads-cmake $(PREFIX)/../src/pthreads-test.c)'; \
echo 'target_link_libraries(test-pthreads-cmake $${CMAKE_THREAD_LIBS_INIT})'; \
echo 'install(TARGETS test-pthreads-cmake DESTINATION bin)'; \
) > '$(1).cmake/CMakeLists.txt'
cd '$(1).cmake' && '$(TARGET)-cmake' .
$(MAKE) -C '$(1).cmake' -j 1 install
mkdir '$(1).test-cmake'
cd '$(1).test-cmake' && '$(TARGET)-cmake' \
-DPKG=$(PKG) \
'$(PWD)/src/cmake/test'
$(MAKE) -C '$(1).test-cmake' -j 1 install
endef

15
src/sdl-test.cmake Normal file
View File

@ -0,0 +1,15 @@
# This file is part of MXE.
# See index.html for further information.
# partial module - included by src/cmake/CMakeLists.txt
set(TGT test-${PKG}-cmake)
enable_language(C)
add_executable(${TGT} ${CMAKE_CURRENT_LIST_DIR}/${PKG}-test.c)
find_package(SDL ${PKG_VERSION} EXACT REQUIRED)
include_directories(${SDL_INCLUDE_DIRS})
target_link_libraries(${TGT} ${SDL_LIBRARIES})
install(TARGETS ${TGT} DESTINATION bin)

View File

@ -36,15 +36,9 @@ define $(PKG)_BUILD
# test cmake
mkdir '$(1).test-cmake'
(echo 'cmake_minimum_required(VERSION 2.8.11)'; \
echo 'project(test-$(PKG)-cmake)'; \
echo 'find_package(SDL REQUIRED)'; \
echo 'include_directories($${SDL_INCLUDE_DIRS})'; \
echo 'add_executable(test-$(PKG)-cmake $(PREFIX)/../src/$(PKG)-test.c)'; \
echo 'target_link_libraries(test-$(PKG)-cmake $${SDL_LIBRARIES})'; \
echo 'install(TARGETS test-$(PKG)-cmake DESTINATION bin)'; \
) > '$(1).test-cmake/CMakeLists.txt'
cd '$(1).test-cmake' && '$(TARGET)-cmake' .
cd '$(1).test-cmake' && '$(TARGET)-cmake' \
-DPKG=$(PKG) \
-DPKG_VERSION=$($(PKG)_VERSION) \
'$(PWD)/src/cmake/test'
$(MAKE) -C '$(1).test-cmake' -j 1 install
endef

View File

@ -0,0 +1,18 @@
# This file is part of MXE.
# See index.html for further information.
# partial module - included by src/cmake/CMakeLists.txt
set(TGT test-${PKG}-cmake)
enable_language(C)
add_executable(${TGT} ${CMAKE_CURRENT_LIST_DIR}/pthreads-test.c)
find_package(Threads REQUIRED)
if(Threads::Threads) # cmake 3.1.0+
target_link_libraries(${TGT} Threads::Threads)
else()
target_link_libraries(${TGT} ${CMAKE_THREAD_LIBS_INIT})
endif()
install(TARGETS ${TGT} DESTINATION bin)