Skip to content

Commit

Permalink
fix: fix the linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Mar 31, 2023
1 parent 0a9754a commit 758c49f
Show file tree
Hide file tree
Showing 20 changed files with 309 additions and 148 deletions.
11 changes: 6 additions & 5 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,12 @@ tasks:
- lint.cspell
- lint.clang-format
- lint.cmake
- myproj:lint
- install:lint
- minimal:lint
- emscripten:lint
- rpi4-vcpkg:lint
cmds:
- task: myproj:lint
- task: install:lint
- task: minimal:lint
- task: emscripten:lint
- task: rpi4-vcpkg:lint

clean:
- cmd: powershell -c 'function rmrf($path) { if (test-path $path) { rm -r -force $path }}; rmrf ./install'
Expand Down
17 changes: 15 additions & 2 deletions cspell.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ language: en, en-GB
allowCompoundWords: true
enableGlobDot: true
words:
- awalsh
- pkgs
- aarch
- aminya
- Amnet
Expand All @@ -20,6 +18,7 @@ words:
- ARGN
- armv
- asan
- awalsh
- buildtools
- ccache
- ccmake
Expand All @@ -42,11 +41,13 @@ words:
- DDEFAULT_TRIPLET
- deps
- DOPT
- DVCPKG
- dyld
- dylib
- eabi
- egor-tensin
- Eigen
- elif
- emcc
- emcmake
- emscripten
Expand All @@ -72,9 +73,11 @@ words:
- LPWSTR
- lrdimon
- lstdc
- mathjax
- mcpu
- mdfile
- mfpu
- moderncmakedomain
- msbuild
- msvc
- msys
Expand All @@ -87,13 +90,20 @@ words:
- myprogram
- myproj
- myproject
- mypy
- mythirdpartylib
- nojekyll
- nosys
- nothrow
- nvcc
- Opencppcoverage
- pargs
- pkgs
- pnpm
- POSIX
- pwsh
- qthelp
- riscv
- rmrf
- rpath
- rtti
Expand All @@ -103,9 +113,11 @@ words:
- suppr
- SYSROOT
- tecolicom
- texi
- TOLOWER
- TOUPPER
- ubsan
- undoc
- vcpkg
- vcvarsall
- visualc
Expand All @@ -131,5 +143,6 @@ words:
- Wsign
- Wunused
- Wuseless
- Xcompiler
- xcrun
- Yahyaabadi
10 changes: 5 additions & 5 deletions docker/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ tasks:
- docker-compose up --build minimal-build-mingw-x64-from-triplet
- docker-compose up --build minimal-build-mingw-x86
- docker-compose down

emscripten:
- docker-compose up --build build-emscripten
- docker-compose down
Expand All @@ -33,7 +33,7 @@ tasks:
rpi3.bare-metal:
- docker-compose up --build build-rpi3-bare-metal
- docker-compose down

rpi4:
- docker-compose up --build build-rpi4
- docker-compose down
Expand All @@ -49,7 +49,7 @@ tasks:
rpi4.custom:
- docker-compose up --build build-rpi4-custom
- docker-compose down

rpi4.aarch64:
- docker-compose up --build build-rpi4-aarch64
- docker-compose down
Expand All @@ -58,6 +58,6 @@ tasks:
- docker-compose up --build build-rpi4-vcpkg
- docker-compose down

rpi4.vcpkg-custsom:
rpi4.vcpkg-custom:
- docker-compose up --build build-rpi4-vcpkg-custom
- docker-compose down
- docker-compose down
4 changes: 3 additions & 1 deletion docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ set(conf_version "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VE
set(conf_release "${PROJECT_VERSION}")
set(conf_name "project_options")
set(conf_author "Amin Yahyaabadi")
set(conf_brief "A general-purpose CMake library that provides functions that improve the CMake experience following the best practices.")
set(conf_brief
"A general-purpose CMake library that provides functions that improve the CMake experience following the best practices."
)
set(conf_doxygen_input
"\
\"${CMAKE_SOURCE_DIR}/include\" \
Expand Down
2 changes: 1 addition & 1 deletion docs/cmake/FindSphinx.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if(NOT SPHINX_EXECUTABLE)
find_program(
SPHINX_EXECUTABLE
NAMES ${_sphinx_NAMES}
PATHS /usr/bin /usr/local/bin /opt/loca/bin
PATHS /usr/bin /usr/local/bin /opt/local/bin
DOC "Sphinx documentation generator")
endforeach()
endif()
Expand Down
31 changes: 19 additions & 12 deletions src/Common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -80,26 +80,33 @@ macro(common_project_options)
execute_process(
COMMAND reg query "HKU\\S-1-5-19"
ERROR_VARIABLE IS_NONADMINISTRATOR
OUTPUT_QUIET
)
OUTPUT_QUIET)
else()
set(IS_NONADMINISTRATOR "")
endif()

if(IS_NONADMINISTRATOR)
# For non-administrator, create an auxiliary target and ask user to run it
add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/compile_commands.json
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/compile_commands.json ${CMAKE_SOURCE_DIR}/compile_commands.json
DEPENDS ${CMAKE_BINARY_DIR}/compile_commands.json
VERBATIM
)
add_custom_target(_copy_compile_commands
DEPENDS ${CMAKE_SOURCE_DIR}/compile_commands.json
VERBATIM
add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/compile_commands.json
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/compile_commands.json
${CMAKE_SOURCE_DIR}/compile_commands.json
DEPENDS ${CMAKE_BINARY_DIR}/compile_commands.json
VERBATIM)
add_custom_target(
_copy_compile_commands
DEPENDS ${CMAKE_SOURCE_DIR}/compile_commands.json
VERBATIM)
message(
STATUS
"compile_commands.json was not symlinked to the root. Run `cmake --build <build_dir> -t _copy_compile_commands` if needed."
)
message(STATUS "compile_commands.json was not symlinked to the root. Run `cmake --build <build_dir> -t _copy_compile_commands` if needed.")
else()
file(CREATE_LINK ${CMAKE_BINARY_DIR}/compile_commands.json ${CMAKE_SOURCE_DIR}/compile_commands.json SYMBOLIC)
file(
CREATE_LINK
${CMAKE_BINARY_DIR}/compile_commands.json
${CMAKE_SOURCE_DIR}/compile_commands.json
SYMBOLIC)
message(TRACE "compile_commands.json was symlinked to the root.")
endif()

Expand Down
66 changes: 50 additions & 16 deletions src/CrossCompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@ macro(enable_cross_compiler)
"${oneValueArgs}"
"${multiValueArgs}"
${ARGN})

include("${ProjectOptions_SRC_DIR}/Utilities.cmake")
detect_architecture(_arch)

set(_default_triplet ${DEFAULT_TRIPLET})
if(NOT "${EnableCrossCompiler_DEFAULT_TRIPLET}" STREQUAL "")
if(NOT
"${EnableCrossCompiler_DEFAULT_TRIPLET}"
STREQUAL
"")
set(_default_triplet ${EnableCrossCompiler_DEFAULT_TRIPLET})
endif()

Expand All @@ -32,25 +35,40 @@ macro(enable_cross_compiler)
endif()
set(_cc ${CMAKE_C_COMPILER})
set(_cxx ${CMAKE_CXX_COMPILER})
if(NOT "${EnableCrossCompiler_CC}" STREQUAL "")
if(NOT
"${EnableCrossCompiler_CC}"
STREQUAL
"")
set(_cc ${EnableCrossCompiler_CC})
endif()
if(NOT "${EnableCrossCompiler_CXX}" STREQUAL "")
if(NOT
"${EnableCrossCompiler_CXX}"
STREQUAL
"")
set(_cxx ${EnableCrossCompiler_CXX})
endif()

set(_target_architecture ${TARGET_ARCHITECTURE})
if(NOT "${EnableCrossCompiler_TARGET_ARCHITECTURE}" STREQUAL "")
if(NOT
"${EnableCrossCompiler_TARGET_ARCHITECTURE}"
STREQUAL
"")
set(_target_architecture ${EnableCrossCompiler_TARGET_ARCHITECTURE})
endif()

set(_cross_root ${CROSS_ROOT})
if(NOT "${EnableCrossCompiler_CROSS_ROOT}" STREQUAL "")
if(NOT
"${EnableCrossCompiler_CROSS_ROOT}"
STREQUAL
"")
set(_cross_root ${EnableCrossCompiler_CROSS_ROOT})
endif()

set(_cross_triplet ${CROSS_TRIPLET})
if(NOT "${EnableCrossCompiler_CROSS_TRIPLET}" STREQUAL "")
if(NOT
"${EnableCrossCompiler_CROSS_TRIPLET}"
STREQUAL
"")
set(_cross_triplet ${EnableCrossCompiler_CROSS_TRIPLET})
endif()

Expand Down Expand Up @@ -176,7 +194,7 @@ macro(enable_cross_compiler)
set(LIBRARY_LINKAGE "static")
endif()
endif()

if(_cc MATCHES "x86_64(-w64)?-mingw32-[gc]..?" OR _cxx MATCHES "x86_64(-w64)?-mingw32-[gc]..?")
if("${_cross_root}" STREQUAL "")
set(_cross_root "/usr/x86_64-w64-mingw32")
Expand Down Expand Up @@ -221,7 +239,11 @@ macro(enable_cross_compiler)
set(USE_CROSSCOMPILER_ARM_NONE TRUE)
endif()
# TODO: check if path is right, check for header files or something
if(NOT "${_cross_root}" STREQUAL "" AND "${_cross_triplet}" STREQUAL "")
if(NOT
"${_cross_root}"
STREQUAL
""
AND "${_cross_triplet}" STREQUAL "")
message(WARNING "CROSS_ROOT (${_cross_root}) is set, but CROSS_TRIPLET is not")
endif()

Expand Down Expand Up @@ -270,7 +292,10 @@ macro(enable_cross_compiler)
endif()

set(_toolchain_file)
if(NOT "${EnableCrossCompiler_TOOLCHAIN_FILE}" STREQUAL "")
if(NOT
"${EnableCrossCompiler_TOOLCHAIN_FILE}"
STREQUAL
"")
set(_toolchain_file ${EnableCrossCompiler_TOOLCHAIN_FILE})
else()
get_toolchain_file(_toolchain_file)
Expand All @@ -283,7 +308,7 @@ macro(enable_cross_compiler)
set(CROSS_TOOLCHAIN_FILE ${VCPKG_CHAINLOAD_TOOLCHAIN_FILE})
endif()
else()
set(CROSS_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE})
set(CROSS_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE})
endif()
set(CROSSCOMPILING TRUE)

Expand All @@ -302,16 +327,25 @@ macro(enable_cross_compiler)
#message(STATUS "EMSDK: $ENV{EMSDK}")
message(STATUS "use emscripten cross-compiler emulator: ${CMAKE_CROSSCOMPILING_EMULATOR}")
else()
if(NOT "${CROSS_ROOT}" STREQUAL "")
if(NOT
"${CROSS_ROOT}"
STREQUAL
"")
message(STATUS "use SYSROOT: ${CROSS_ROOT}")
endif()
endif()
message(STATUS "Target Architecture: ${TARGET_ARCHITECTURE}")
if(NOT "${DEFAULT_TRIPLET}" STREQUAL "")
if(NOT
"${DEFAULT_TRIPLET}"
STREQUAL
"")
message(STATUS "Default Triplet: ${DEFAULT_TRIPLET}")
endif()
message(STATUS "Host Triplet: ${HOST_TRIPLET}")
if(NOT "${CMAKE_TOOLCHAIN_FILE}" STREQUAL "")
if(NOT
"${CMAKE_TOOLCHAIN_FILE}"
STREQUAL
"")
message(STATUS "Toolchain File: ${CMAKE_TOOLCHAIN_FILE}")
else()
if(NOT DEFINED VCPKG_CHAINLOAD_TOOLCHAIN_FILE)
Expand Down
1 change: 0 additions & 1 deletion src/Index.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ msvc_toolchain()
include("${CMAKE_CURRENT_LIST_DIR}/Conan.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/Vcpkg.cmake")


#[[.rst:

.. include:: ../../docs/src/project_options.rst
Expand Down
Loading

0 comments on commit 758c49f

Please sign in to comment.