mirror of
https://github.com/ashaduri/gsmartcontrol.git
synced 2026-09-25 05:15:33 +00:00
Implement toolchain support for cross-compilation and development.
This commit is contained in:
+5
-1
@@ -10,7 +10,11 @@ cmake_minimum_required(VERSION 3.13)
|
||||
|
||||
include(${CMAKE_SOURCE_DIR}/version.txt)
|
||||
|
||||
project(gsmartcontrol VERSION ${CMAKE_PROJECT_VERSION})
|
||||
project(gsmartcontrol
|
||||
VERSION ${CMAKE_PROJECT_VERSION}
|
||||
HOMEPAGE_URL "https://gsmartcontrol.shaduri.dev"
|
||||
LANGUAGES CXX
|
||||
)
|
||||
|
||||
|
||||
# Provide DATADIR, etc...
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
###############################################################################
|
||||
# License: BSD Zero Clause License file
|
||||
# Copyright:
|
||||
# (C) 2021 Alexander Shaduri <ashaduri@gmail.com>
|
||||
###############################################################################
|
||||
|
||||
# Enable building examples by default
|
||||
set(APP_BUILD_EXAMPLES ON)
|
||||
@@ -1,47 +0,0 @@
|
||||
###############################################################################
|
||||
# License: BSD Zero Clause License file
|
||||
# Copyright:
|
||||
# (C) 2021 Alexander Shaduri <ashaduri@gmail.com>
|
||||
###############################################################################
|
||||
|
||||
|
||||
# Enable LTO for Release mode
|
||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON)
|
||||
|
||||
# Add compiler options for development
|
||||
add_compile_options(
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wpedantic
|
||||
-Wshadow
|
||||
-Wpointer-arith
|
||||
-Wundef
|
||||
-Wunused-macros
|
||||
-Wcast-qual
|
||||
-Wcast-align
|
||||
-Wconversion
|
||||
-Wmissing-declarations
|
||||
-Wpacked
|
||||
-Wredundant-decls
|
||||
-Wvla
|
||||
-Woverlength-strings
|
||||
-Wnon-virtual-dtor
|
||||
-Woverloaded-virtual
|
||||
-Wno-missing-field-initializers
|
||||
-Wdate-time
|
||||
-Wregister
|
||||
)
|
||||
|
||||
# -fvisibility-inlines-hidden hides inline functions of exported classes.
|
||||
# This switch declares that the user does not attempt to compare pointers to inline functions
|
||||
# or methods where the addresses of the two functions are taken in different shared objects.
|
||||
# Dramatically improves load an link times with DSOs (with templates).
|
||||
set(CMAKE_VISIBILITY_INLINES_HIDDEN TRUE)
|
||||
|
||||
# -fvisibility=hidden hides all symbols by default (like MSVC); this reduces symbol tables
|
||||
# for shared libraries and avoids unneeded exports.
|
||||
add_compile_options(
|
||||
-fvisibility=hidden
|
||||
)
|
||||
|
||||
#target_compile_options(foo PUBLIC "$<$<CONFIG:DEBUG>:${MY_DEBUG_OPTIONS}>")
|
||||
@@ -1,33 +0,0 @@
|
||||
###############################################################################
|
||||
# License: BSD Zero Clause License file
|
||||
# Copyright:
|
||||
# (C) 2021 Alexander Shaduri <ashaduri@gmail.com>
|
||||
###############################################################################
|
||||
|
||||
# Linux development version with clang, debug mode.
|
||||
# Use with:
|
||||
# cmake -DCMAKE_TOOLCHAIN_FILE=...
|
||||
|
||||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
|
||||
# Specify the compiler
|
||||
set(CMAKE_C_COMPILER clang)
|
||||
set(CMAKE_CXX_COMPILER clang++)
|
||||
|
||||
# Common options for gcc/clang
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/common-gcc-clang.cmake)
|
||||
|
||||
# Common options for development
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/common-dev.cmake)
|
||||
|
||||
# Clang-specific options
|
||||
add_compile_options(
|
||||
-Wdocumentation
|
||||
-Wheader-guard
|
||||
-Wloop-analysis
|
||||
-Wno-keyword-macro
|
||||
)
|
||||
|
||||
|
||||
# Enable clang-tidy by default, reading from <project_root>/.clang-tidy file
|
||||
set(CMAKE_CXX_CLANG_TIDY "clang-tidy")
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
|
||||
# Enable clang-tidy by default, reading from <project_root>/.clang-tidy file
|
||||
set(CMAKE_CXX_CLANG_TIDY "clang-tidy")
|
||||
|
||||
|
||||
# Developer options
|
||||
set(APP_COMPILER_ENABLE_WARNINGS ON)
|
||||
set(APP_BUILD_EXAMPLES ON)
|
||||
set(APP_BUILD_TESTS ON)
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
###############################################################################
|
||||
# License: BSD Zero Clause License file
|
||||
# Copyright:
|
||||
# (C) 2021 Alexander Shaduri <ashaduri@gmail.com>
|
||||
###############################################################################
|
||||
|
||||
# Windows 32-bit production version with mingw/gcc.
|
||||
# Use with:
|
||||
# cmake -DCMAKE_TOOLCHAIN_FILE=...
|
||||
|
||||
# Target OS
|
||||
set(CMAKE_SYSTEM_NAME Windows)
|
||||
|
||||
# Specify the compiler
|
||||
set(CMAKE_C_COMPILER i686-w64-mingw32-gcc)
|
||||
set(CMAKE_CXX_COMPILER i686-w64-mingw32-g++)
|
||||
#set(CMAKE_RC_COMPILER i686-w64-mingw32-windres)
|
||||
|
||||
# The target environment
|
||||
set(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32/sys-root/mingw)
|
||||
|
||||
# Adjust the default behaviour of the FIND_XXX() commands:
|
||||
# search headers and libraries in the target environment, search
|
||||
# programs in the 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_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
|
||||
IF (CMAKE_CROSSCOMPILING)
|
||||
set(ENV{PKG_CONFIG_LIBDIR} "${CMAKE_FIND_ROOT_PATH}/lib/pkgconfig")
|
||||
endif()
|
||||
|
||||
#set(APP_NSIS_PATH /usr/bin/makensis)
|
||||
|
||||
|
||||
# Enable LTO for Release build
|
||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON)
|
||||
|
||||
# Increase optimizations of Release builds
|
||||
add_compile_options("$<$<CONFIG:RELEASE>:-g0 -O3 -s>")
|
||||
|
||||
# Enable common CPU optimizations
|
||||
add_compile_options(-march=i686 -mtune=generic)
|
||||
|
||||
|
||||
# Developer options
|
||||
set(APP_COMPILER_ENABLE_WARNINGS ON)
|
||||
set(APP_BUILD_EXAMPLES ON)
|
||||
set(APP_BUILD_TESTS ON)
|
||||
|
||||
|
||||
@@ -8,24 +8,16 @@
|
||||
# Use with:
|
||||
# cmake -DCMAKE_TOOLCHAIN_FILE=...
|
||||
|
||||
# TODO
|
||||
# # optimized builds (target mingw32):
|
||||
## -g0 -O3 -s -march=i686
|
||||
#
|
||||
## optimized builds (target mingw64, cygwin):
|
||||
## -g0 -O3 -s
|
||||
|
||||
# -mtune=generic
|
||||
|
||||
# Target OS
|
||||
set(CMAKE_SYSTEM_NAME Windows)
|
||||
|
||||
# Specify the compiler
|
||||
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
|
||||
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
|
||||
set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
|
||||
#set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
|
||||
|
||||
# The target environment
|
||||
set(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32/sys-root/mingw)
|
||||
set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32/sys-root/mingw)
|
||||
|
||||
# Adjust the default behaviour of the FIND_XXX() commands:
|
||||
# search headers and libraries in the target environment, search
|
||||
@@ -35,8 +27,26 @@ set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
|
||||
# Common options for gcc
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/common-gcc-clang.cmake)
|
||||
IF (CMAKE_CROSSCOMPILING)
|
||||
set(ENV{PKG_CONFIG_LIBDIR} "${CMAKE_FIND_ROOT_PATH}/lib/pkgconfig")
|
||||
endif()
|
||||
|
||||
#set(APP_NSIS_PATH /usr/bin/makensis)
|
||||
|
||||
|
||||
# Enable LTO for Release build
|
||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON)
|
||||
|
||||
# Increase optimizations of Release builds
|
||||
add_compile_options("$<$<CONFIG:RELEASE>:-g0 -O3 -s>")
|
||||
|
||||
# Enable common CPU optimizations
|
||||
add_compile_options(-mtune=generic)
|
||||
|
||||
|
||||
# Developer options
|
||||
set(APP_COMPILER_ENABLE_WARNINGS ON)
|
||||
set(APP_BUILD_EXAMPLES ON)
|
||||
set(APP_BUILD_TESTS ON)
|
||||
|
||||
set(APP_NSIS_PATH /usr/bin/makensis)
|
||||
|
||||
Reference in New Issue
Block a user