Skip to content

Commit

Permalink
CMake refactor (#105)
Browse files Browse the repository at this point in the history
* Major CMake refactor

* CI fixes

* Fix CMake errors

* Install graphviz on Windows

* More consistent CMake build types

* Fix compiler defines for Windows

* Fix more bugs

* Add standalone tool building support

* Fix typo

* Update README

* Install sleighLift before trying to smoketest it

* Test coverage preset

The compiler option '-fkeep-inline-functions' originally included with
the coverage build type causes errors with the message "undefined
reference to 'vtable for OpAction*'" for all OpAction subclasses.

This StackOverflow answer might help in resolving this?
https://stackoverflow.com/a/57504289

* Build documentation by default with CI presets

* Use COMPONENT for install commands

This allows for someone to specify which components they want to install
if they only want or need a subset

* Support cross compiling with host system sleigh compiler

* Various fixes found during review

* Move "_WINDOWS" define to CMakeLists.txt file

* Rename ToB 'tools' directory to 'extra-tools'

* Separate projects for sleigh tools

Library is still top-level CMakeLists.txt

More options

* CMake find_package(Git)

* Fix bad merge for patch paths

* Fix missing libconfig.h header install

* Fix issues with installation of headers

* More refactoring

* Refactor sleighexample into its own project/directory

* Refactor specfiles building into separate project/directory

* Check for termios.h header and set define if found

* Update READMEs

* Better consistency with install rules

* Build sleighLift as a standalone project with added source

* More changes to CMake subprojects

* Also add "Specs" component to sleigh installation config

* Try to be better at bootstrapping subprojects (hopefully this doesn't
  bite us, but if it does, I'm happy to remove it and say "not
  supported")

* Address some code review

* Add project sleigh_tool for tool subdirectory

Could make it easier to build just the tools

* Add help text to name the tool executable name

* Add license notice to CMake files

* Fix/Remove too specific CPack packaging configuration

* Consistent capitalization of Sleigh

Co-authored-by: Alex Cameron <asc@tetsuo.sh>
  • Loading branch information
ekilmer and tetsuo-cpp committed Aug 22, 2022
1 parent 72d364a commit 74838a3
Show file tree
Hide file tree
Showing 52 changed files with 1,505 additions and 887 deletions.
57 changes: 33 additions & 24 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,16 @@ jobs:
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y \
clang \
rpm \
sudo apt-get install -y rpm
# Use Homebrew for latest build tools for use in CI
brew install \
cmake \
ccache \
doxygen \
xdot \
graphviz
# Minimum supported CMake version testing
curl -L "https://github.com/Kitware/CMake/releases/download/v3.18.0/cmake-3.18.0-Linux-$(uname -m).sh" -o /tmp/cmake-install.sh
mkdir -p "${HOME}/.local"
bash /tmp/cmake-install.sh --skip-license --exclude-subdir "--prefix=${HOME}/.local"
# Use Homebrew for latest build tool version for use in CI
brew install \
ccache
- name: Install macOS system dependencies
if: runner.os == 'macOS'
run: |
Expand All @@ -65,7 +59,7 @@ jobs:
- name: Install Windows system dependencies
if: runner.os == 'Windows'
run: choco install ccache
run: choco install ccache doxygen.install graphviz

- name: Generate cache key
id: cache_key
Expand Down Expand Up @@ -96,24 +90,20 @@ jobs:
# This should be multiplied by the number of compilation jobs and be no
# larger than 5G, which is the cache max size
file(APPEND "$ENV{GITHUB_ENV}" "CCACHE_MAXSIZE=400M\n")
# Tell CMake to use ccache
file(APPEND "$ENV{GITHUB_ENV}" "CMAKE_CXX_COMPILER_LAUNCHER=ccache\n")
file(APPEND "$ENV{GITHUB_ENV}" "CMAKE_C_COMPILER_LAUNCHER=ccache\n")
# Clear stats before every build
execute_process(COMMAND ccache -z)
- name: CMake version
run: cmake --version

- name: Configure the project
run: cmake
-S .
-B build
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
-DCMAKE_C_COMPILER_LAUNCHER=ccache
shell: pwsh
run: cmake "--preset=ci-$("${{ matrix.os }}".split("-")[0])"
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-Dsleigh_RELEASE_TYPE=${{ matrix.release }}
-Dsleigh_ENABLE_TESTS=ON
-Dsleigh_ENABLE_EXAMPLES=ON
-Dsleigh_ENABLE_PACKAGING=ON
-Dsleigh_ENABLE_DOCUMENTATION=ON

- name: Build the project
run: cmake
Expand All @@ -122,18 +112,28 @@ jobs:
-j 2
-v

- name: Build the docs
run: cmake
--build build
--config ${{ matrix.build_type }}
--target docs
-v

- name: Run the example
run: cmake
--build build
-j 2
--config ${{ matrix.build_type }}
--target sleighexample_runner
--target sleigh_example_runner

- name: Run the install target
run: cmake --install build
--config ${{ matrix.build_type }}
--prefix install

- name: Smoketest sleigh lift
run: ./install/bin/sleigh-lift disassemble x86-64.sla 4881ecc00f0000

- name: Test install directory
working-directory: tests/find_package
run: |
Expand All @@ -142,6 +142,15 @@ jobs:
cd build
ctest -V -C ${{ matrix.build_type }}
- name: Test tool install directory
working-directory: extra-tools/sleigh-lift
run: |
cmake -B build -S . "-Dsleigh_DIR=${{ github.workspace }}/install/lib/cmake/sleigh" -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
cmake --build build -j 2 --config ${{ matrix.build_type }}
cmake --install build --config ${{ matrix.build_type }} --prefix install
./install/bin/sleigh-lift --version
./install/bin/sleigh-lift disassemble x86-64.sla 4881ecc00f0000
- name: Create the packages
run: cmake
--build build
Expand Down Expand Up @@ -224,7 +233,7 @@ jobs:
# failure state
- name: Run the tests
working-directory: build
run: ctest -V -C ${{ matrix.build_type }}
run: ctest -VV -C ${{ matrix.build_type }}

- name: ccache stats
run: ccache -s --verbose
Loading

0 comments on commit 74838a3

Please sign in to comment.