From 415ea9f95f5c2d7f80cfe36d639271a7bb42d542 Mon Sep 17 00:00:00 2001 From: Patrix Date: Mon, 13 Jun 2022 16:53:01 +0200 Subject: [PATCH] Added CI & platform specific toolchain files --- CMakeLists.txt | 8 ++++++++ linux-arm.cmake | 38 ++++++++++++++++++++++++++++++++++++++ linux-arm64.cmake | 38 ++++++++++++++++++++++++++++++++++++++ linux-x64.cmake | 32 ++++++++++++++++++++++++++++++++ linux-x86.cmake | 32 ++++++++++++++++++++++++++++++++ windows-x64.cmake | 9 +++++++++ windows-x86.cmake | 9 +++++++++ 7 files changed, 166 insertions(+) create mode 100644 linux-arm.cmake create mode 100644 linux-arm64.cmake create mode 100644 linux-x64.cmake create mode 100644 linux-x86.cmake create mode 100644 windows-x64.cmake create mode 100644 windows-x86.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 754d04e..e3caaac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,14 @@ target_include_directories(SqModule "dependencies/sqrat/include/" ) +if(DEFINED SHARED_LIBRARY_SUFFIX) + set_target_properties(SqModule + PROPERTIES + PREFIX "" + SUFFIX ".${CMAKE_SYSTEM_PROCESSOR}${CMAKE_SHARED_LIBRARY_SUFFIX}" + ) +endif() + if (NOT ${GAME_PATH} STREQUAL "") install(TARGETS SqModule RUNTIME diff --git a/linux-arm.cmake b/linux-arm.cmake new file mode 100644 index 0000000..26bd155 --- /dev/null +++ b/linux-arm.cmake @@ -0,0 +1,38 @@ +# Simple toolchain file for compiling under linux +# Usage: cmake .. -DCMAKE_TOOLCHAIN_FILE=linux-arm.cmake + +# specify the target system properties +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR arm) + +# specify shared library suffix +set(SHARED_LIBRARY_SUFFIX ${CMAKE_SYSTEM_PROCESSOR}) + +if (${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "arm.*") + # specify native compiler + set(CMAKE_C_COMPILER gcc) + set(CMAKE_CXX_COMPILER g++) +else() + # specify cross compiler + set(CMAKE_C_COMPILER arm-linux-gnueabi-gcc) + set(CMAKE_CXX_COMPILER arm-linux-gnueabi-g++) +endif() + +# specify the compiler flags +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc -static-libstdc++") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++") + +# specify the paths for find_(name), functions (target environment). +set(CMAKE_FIND_ROOT_PATH /usr/lib) + +# search only for programs in the build host directories (find_program) +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + +# use only CMAKE_FIND_ROOT_PATH for searching (find_library) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + +# use only CMAKE_FIND_ROOT_PATH for searching (find_file, find_path) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +# use only CMAKE_FIND_ROOT_PATH for searching (find_package) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) diff --git a/linux-arm64.cmake b/linux-arm64.cmake new file mode 100644 index 0000000..c5b631b --- /dev/null +++ b/linux-arm64.cmake @@ -0,0 +1,38 @@ +# Simple toolchain file for compiling under linux +# Usage: cmake .. -DCMAKE_TOOLCHAIN_FILE=linux-arm64.cmake + +# specify the target system properties +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR aarch64) + +# specify shared library suffix +set(SHARED_LIBRARY_SUFFIX "arm64") + +if (${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "aarch64") + # specify native compiler + set(CMAKE_C_COMPILER gcc) + set(CMAKE_CXX_COMPILER g++) +else() + # specify cross compiler + set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc) + set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++) +endif() + +# specify the compiler flags +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc -static-libstdc++") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++") + +# specify the paths for find_(name), functions (target environment). +set(CMAKE_FIND_ROOT_PATH /usr/lib) + +# search only for programs in the build host directories (find_program) +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + +# use only CMAKE_FIND_ROOT_PATH for searching (find_library) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + +# use only CMAKE_FIND_ROOT_PATH for searching (find_file, find_path) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +# use only CMAKE_FIND_ROOT_PATH for searching (find_package) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) diff --git a/linux-x64.cmake b/linux-x64.cmake new file mode 100644 index 0000000..2860f0a --- /dev/null +++ b/linux-x64.cmake @@ -0,0 +1,32 @@ +# Simple toolchain file for compiling under linux +# Usage: cmake .. -DCMAKE_TOOLCHAIN_FILE=linux-x64.cmake + +# specify the target system properties +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR x86_64) + +# specify shared library suffix +set(SHARED_LIBRARY_SUFFIX "x64") + +# specify the compilers +set(CMAKE_C_COMPILER gcc) +set(CMAKE_CXX_COMPILER g++) + +# specify the compiler flags +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc -static-libstdc++") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++") + +# specify the paths for find_(name), functions (target environment). +set(CMAKE_FIND_ROOT_PATH /usr/lib) + +# search only for programs in the build host directories (find_program) +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + +# use only CMAKE_FIND_ROOT_PATH for searching (find_library) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + +# use only CMAKE_FIND_ROOT_PATH for searching (find_file, find_path) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +# use only CMAKE_FIND_ROOT_PATH for searching (find_package) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) diff --git a/linux-x86.cmake b/linux-x86.cmake new file mode 100644 index 0000000..ea6452b --- /dev/null +++ b/linux-x86.cmake @@ -0,0 +1,32 @@ +# Simple toolchain file for compiling under linux +# Usage: cmake .. -DCMAKE_TOOLCHAIN_FILE=linux-x86.cmake + +# specify the target system properties +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR x86) + +# specify shared library suffix +set(SHARED_LIBRARY_SUFFIX ${CMAKE_SYSTEM_PROCESSOR}) + +# specify the compilers +set(CMAKE_C_COMPILER gcc) +set(CMAKE_CXX_COMPILER g++) + +# specify the compiler flags +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32 -static-libgcc -static-libstdc++") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32 -static-libgcc -static-libstdc++") + +# specify the paths for find_(name), functions (target environment). +set(CMAKE_FIND_ROOT_PATH /usr/lib32) + +# search only for programs in the build host directories (find_program) +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + +# use only CMAKE_FIND_ROOT_PATH for searching (find_library) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + +# use only CMAKE_FIND_ROOT_PATH for searching (find_file, find_path) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +# use only CMAKE_FIND_ROOT_PATH for searching (find_package) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) diff --git a/windows-x64.cmake b/windows-x64.cmake new file mode 100644 index 0000000..ed6ccc3 --- /dev/null +++ b/windows-x64.cmake @@ -0,0 +1,9 @@ +# Simple toolchain file for compiling under windows +# Usage: cmake .. -DCMAKE_TOOLCHAIN_FILE=windows-x64.cmake + +# specify the target system properties +set(CMAKE_SYSTEM_NAME Windows) +set(CMAKE_GENERATOR_PLATFORM x64 CACHE INTERNAL "") + +# specify shared library suffix +set(SHARED_LIBRARY_SUFFIX ${CMAKE_GENERATOR_PLATFORM}) diff --git a/windows-x86.cmake b/windows-x86.cmake new file mode 100644 index 0000000..d3d7c95 --- /dev/null +++ b/windows-x86.cmake @@ -0,0 +1,9 @@ +# Simple toolchain file for compiling under windows +# Usage: cmake .. -DCMAKE_TOOLCHAIN_FILE=windows-x86.cmake + +# specify the target system properties +set(CMAKE_SYSTEM_NAME Windows) +set(CMAKE_GENERATOR_PLATFORM Win32 CACHE INTERNAL "") + +# specify shared library suffix +set(SHARED_LIBRARY_SUFFIX "x86")