Improve details in the build system

- add target to run cross compiled Windows binaries with wine
- quit tests if --help has been specified
This commit is contained in:
Martchus 2016-07-16 23:04:22 +02:00
parent 3ead704f1d
commit 8efe38dadf
10 changed files with 45 additions and 1 deletions

View File

@ -71,6 +71,18 @@ if(NOT TARGET install-mingw-w64-strip)
)
endif()
# add target for launching application with wine ensuring the WINEPATH is set correctly so wine is able to find all required *.dll files
# requires script from c++utilities, hence the sources of c++utilities must be present
if(MINGW AND CMAKE_CROSSCOMPILING AND CPP_UTILITIES_SOURCE_DIR)
if(NOT TARGET ${META_PROJECT_NAME}_run)
if(CMAKE_FIND_ROOT_PATH)
list(APPEND RUNTIME_LIBRARY_PATH "${CMAKE_FIND_ROOT_PATH}/bin")
endif()
add_custom_target(${META_PROJECT_NAME}_run COMMAND "${CPP_UTILITIES_SOURCE_DIR}/scripts/wine.sh" "${CMAKE_CURRENT_BINARY_DIR}/${META_PROJECT_NAME}.${WINDOWS_EXT}" ${RUNTIME_LIBRARY_PATH})
add_dependencies(${META_PROJECT_NAME}_run ${META_PROJECT_NAME})
endif()
endif()
# find template for *.desktop files
include(TemplateFinder)
find_template_file("desktop" CPP_UTILITIES APP_DESKTOP_TEMPLATE_FILE)

View File

@ -10,6 +10,9 @@ if(HAS_PARENT)
set(${META_PROJECT_VARNAME}_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" PARENT_SCOPE)
set(${META_PROJECT_VARNAME}_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}" PARENT_SCOPE)
set(${META_PROJECT_NAME}_DIR "${CMAKE_CURRENT_BINARY_DIR}" PARENT_SCOPE)
if(CMAKE_FIND_ROOT_PATH AND MINGW)
set(RUNTIME_LIBRARY_PATH "${CMAKE_CURRENT_BINARY_DIR}" ${RUNTIME_LIBRARY_PATH} PARENT_SCOPE)
endif()
endif()
# stringify the meta data
@ -50,6 +53,8 @@ option(FORCE_OLD_ABI "specifies whether usage of old ABI should be forced" OFF)
if(FORCE_OLD_ABI)
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
message(STATUS "Forcing usage of old CXX11 ABI.")
else()
message(STATUS "Using default CXX11 ABI (not forcing old CX11 ABI).")
endif()
# enable debug-only code when doing a debug build

View File

@ -17,6 +17,7 @@ if(DOT_BIN)
else()
set(HAVE_DOT "NO")
endif()
if(NOT DOXYGEN_BIN)
message(WARNING "Doxygen not found, unable to add target for generating API documentation.")

View File

@ -20,6 +20,7 @@ endif()
# set install destination for the CMake modules, config files and header files
set(HEADER_INSTALL_DESTINATION "${CMAKE_INSTALL_PREFIX}/include")
set(BIN_INSTALL_DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
set(LIB_INSTALL_DESTINATION "${CMAKE_INSTALL_PREFIX}/lib${SELECTED_LIB_SUFFIX}")
set(CMAKE_MODULE_INSTALL_DESTINATION "${CMAKE_INSTALL_PREFIX}/share/${META_PROJECT_NAME}/cmake/modules")
set(CMAKE_CONFIG_INSTALL_DESTINATION "${CMAKE_INSTALL_PREFIX}/share/${META_PROJECT_NAME}/cmake")
@ -34,6 +35,7 @@ configure_package_config_file(
CMAKE_MODULE_INSTALL_DESTINATION
CMAKE_CONFIG_INSTALL_DESTINATION
HEADER_INSTALL_DESTINATION
BIN_INSTALL_DESTINATION
LIB_INSTALL_DESTINATION
)

View File

@ -15,3 +15,15 @@ add_test(NAME ${META_PROJECT_NAME}_cppunit COMMAND ${META_PROJECT_NAME}_tests -p
# add the test executable to the dependencies of the check target
add_dependencies(check ${META_PROJECT_NAME}_tests)
# add target for launching tests with wine ensuring the WINEPATH is set correctly so wine is able to find all required *.dll files
# requires script from c++utilities, hence the sources of c++utilities must be present
if(MINGW AND CMAKE_CROSSCOMPILING AND CPP_UTILITIES_SOURCE_DIR)
if(NOT TARGET ${META_PROJECT_NAME}_run_tests)
if(CMAKE_FIND_ROOT_PATH)
list(APPEND RUNTIME_LIBRARY_PATH "${CMAKE_FIND_ROOT_PATH}/bin")
endif()
add_custom_target(${META_PROJECT_NAME}_run_tests COMMAND "${CPP_UTILITIES_SOURCE_DIR}/scripts/wine.sh" "${CMAKE_CURRENT_BINARY_DIR}/${META_PROJECT_NAME}_tests.${WINDOWS_EXT}" ${RUNTIME_LIBRARY_PATH})
add_dependencies(${META_PROJECT_NAME}_run_tests ${META_PROJECT_NAME})
endif()
endif()

View File

@ -33,7 +33,7 @@ if(MINGW)
"${CMAKE_CURRENT_BINARY_DIR}/resources/windows.rc"
)
# set windres as resource compiler
set(RES_FILES "${CMAKE_CURRENT_BINARY_DIR}/resources/windows.rc")
list(APPEND RES_FILES "${CMAKE_CURRENT_BINARY_DIR}/resources/windows.rc")
set(CMAKE_RC_COMPILER_INIT windres)
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
enable_language(RC)

View File

@ -2,6 +2,7 @@
set(@META_PROJECT_VARNAME@_LIBS "@META_PROJECT_NAME@")
set(@META_PROJECT_VARNAME@_INCLUDE_DIRS "@PACKAGE_HEADER_INSTALL_DESTINATION@")
set(@META_PROJECT_VARNAME@_BIN_DIR "@PACKAGE_BIN_INSTALL_DESTINATION@")
set(@META_PROJECT_VARNAME@_LIB_DIR "@PACKAGE_LIB_INSTALL_DESTINATION@")
set(@META_PROJECT_VARNAME@_MODULE_DIRS "@PACKAGE_CMAKE_MODULE_INSTALL_DESTINATION@")
set(@META_PROJECT_VARNAME@_CONFIG_DIRS "@PACKAGE_CMAKE_CONFIG_INSTALL_DESTINATION@")

View File

@ -6,4 +6,5 @@
# define APP_AUTHOR @META_APP_AUTHOR_STR@
# define APP_URL @META_APP_URL_STR@
# define APP_DESCRIPTION @META_APP_DESCRIPTION_STR@
# define APP_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@"
#endif // APP_METADATA_AVAIL

6
scripts/wine.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
for arg in "${@:2}"; do
WINEPATH="${arg};${WINEPATH}"
done
export WINEPATH;
wine "${@:1:1}"

View File

@ -69,6 +69,10 @@ TestApplication::TestApplication(int argc, char **argv) :
// parse arguments
try {
m_parser.parseArgs(argc, argv);
if(m_helpArg.isPresent()) {
m_valid = false;
exit(0);
}
cerr << "Directories used to search for testfiles:" << endl;
if(m_testFilesPathArg.isPresent()) {
if(*m_testFilesPathArg.values().front()) {