From eecbc755ceb88f7ed08f7b9b8fb5f185d9add1e2 Mon Sep 17 00:00:00 2001 From: lukas-heiligenbrunner Date: Thu, 24 Oct 2019 22:00:58 +0200 Subject: [PATCH] temp commit --- CMakeLists.txt | 92 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 87 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c82b7c..4f7c3c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,8 +5,21 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_BUILD_TYPE Release) # manually set build type (Release / Debug) set(libmethod STATIC) #SHARED / STATIC +set(WinBuild false) + +if (NOT ${WinBuild}) +else() +endif () find_package(CURL REQUIRED) +if(CURL_FOUND) + message(STATUS "Found CURL version: ${CURL_VERSION_STRING}") + message(STATUS "Using CURL include dir(s): ${CURL_INCLUDE_DIRS}") + message(STATUS "Using CURL lib(s): ${CURL_LIBRARIES}") + # include_directories(${CURL_INCLUDE_DIRS}) +else() + message(FATAL_ERROR "Could not find CURLLL") +endif() include_directories(${CURL_INCLUDE_DIR} inc) add_library(api ${libmethod} @@ -78,11 +91,80 @@ IF (UNIX) INCLUDE(CPack) + add_custom_target(build-linux-packages + "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target package + DEPENDS ${PROJECT_NAME} + COMMENT "Installing ${PROJECT_NAME}") ENDIF (UNIX) -#todo all -add_custom_target(build-linux-packages - "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target package - DEPENDS ${PROJECT_NAME} - COMMENT "Installing ${PROJECT_NAME}") + + + +#todooooooo + + + +cmake_minimum_required(VERSION 3.14) +project(crosscompiletest) + +set(CMAKE_CXX_STANDARD 14) + +set(WinBuild true) + +if (${WinBuild}) + set(LIBSUFFIX .dll) + set(SUFFIX .exe) +else() + set(LIBSUFFIX .so) + set(SUFFIX "") +endif () + +if (${WinBuild}) + set(CMAKE_SYSTEM_NAME Windows) + set(TOOLCHAIN_PREFIX x86_64-w64-mingw32) + #set(TOOLCHAIN_PREFIX i686-w64-mingw32) + + # cross compilers to use for C and C++ + #set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc) + #set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++) + set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc) + set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++) + set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres) + + # target environment on the build host system + set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX} /usr/lib/gcc/${TOOLCHAIN_PREFIX}/8.3.0) + + + # modify default behavior of FIND_XXX() commands to + # search for headers/libs in the target environment and + # search for programs in the build host environment + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + + set(CMAKE_CXX_STANDARD_LIBRARIES "-static-libgcc -static-libstdc++ -lpthread -lstdc++ -lwsock32 -lws2_32 ${CMAKE_CSS_STANDARD_LIBRARIES}") + set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-Bstatic,--whole-archive -Wl,--no-whole-archive") + +endif () + + +find_package(CURL REQUIRED) +if(CURL_FOUND) + message(STATUS "Found CURL version: ${CURL_VERSION_STRING}") + message(STATUS "Using CURL include dir(s): ${CURL_INCLUDE_DIRS}") + message(STATUS "Using CURL lib(s): ${CURL_LIBRARIES}") + # include_directories(${CURL_INCLUDE_DIRS}) +else() + message(FATAL_ERROR "Could not find CURLLL") +endif() + + +add_library(testlib SHARED testlibrary.cpp testlibrary.h) +set_target_properties(testlib PROPERTIES SUFFIX ${LIBSUFFIX}) + + +add_executable(crosscompiletest main.cpp ) +set_target_properties(crosscompiletest PROPERTIES SUFFIX ${SUFFIX}) + +target_link_libraries(crosscompiletest testlib)