Skip to content

Commit 995c92f

Browse files
author
Conor
committed
squash module skeleton + basic CI
module test files tmp clangd copy over presets formatting interface -> public use toolchain xcrun apple gated bump error comments tmp workflow preset use toolchain naive ctest use alises use a module move to src add libfiles add project call to tests gh action ubuntu mirror casing downgrade to warn Revert "downgrade to warn" This reverts commit 90d9360. no prefix path rm umbuntu workflow lints fix spelling no bundle deps correct version test a linux gcc build rm bundle try ninja in path reoder just lower case rm dead variable Revert "just lower case" This reverts commit 351abe4. Revert "reoder" This reverts commit 366acd5. tmp re-order the other way move back to legacy unify dont specify versions versioned
1 parent db2633e commit 995c92f

File tree

15 files changed

+389
-68
lines changed

15 files changed

+389
-68
lines changed

.clangd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
CompileFlags:
2-
CompilationDatabase: build/dev
2+
CompilationDatabase: build/llvm-brew
3+

.github/workflows/lint.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: ["modules"]
6+
pull_request:
7+
branches: ["modules"]
8+
workflow_dispatch:
9+
10+
jobs:
11+
lint:
12+
runs-on: macos-latest
13+
14+
steps:
15+
- uses: actions/checkout@v6
16+
17+
- name: Set up Homebrew
18+
uses: Homebrew/actions/setup-homebrew@master
19+
20+
- name: Install Dependencies
21+
run: brew install clang-format codespell
22+
23+
- name: Run codespell
24+
run: codespell
25+
26+
- name: Run clang-format
27+
run: |
28+
find src include test -name "*.cpp" -o -name "*.hpp" -o -name "*.cxx" | xargs clang-format --dry-run --Werror

.github/workflows/linux.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Linux
2+
3+
on:
4+
push:
5+
branches: ["modules"]
6+
pull_request:
7+
branches: ["modules"]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build-and-test:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v6
16+
17+
- name: Set up Homebrew
18+
uses: Homebrew/actions/setup-homebrew@master
19+
20+
- name: Install Dependencies
21+
run: brew install cmake ninja gcc
22+
23+
- name: Configure, Build, and Test
24+
run: cmake --workflow --preset gcc-brew

.github/workflows/macos.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: MacOS
2+
3+
on:
4+
push:
5+
branches: ["modules"]
6+
pull_request:
7+
branches: ["modules"]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build-and-test:
12+
runs-on: macos-latest
13+
14+
steps:
15+
- uses: actions/checkout@v6
16+
17+
- name: Set up Homebrew
18+
uses: Homebrew/actions/setup-homebrew@master
19+
20+
- name: Install Dependencies
21+
run: brew install cmake ninja llvm
22+
23+
- name: Configure, Build, and Test
24+
run: cmake --workflow --preset llvm-brew

CMakeLists.txt

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "d0edc3af-4c50-42ea-a356-e2862fe7a444")
55

66
include(cmake/read_version.cmake)
77

8-
read_version(${CMAKE_CURRENT_SOURCE_DIR}/include/libfork/core/macro.hpp)
8+
read_version(${CMAKE_CURRENT_SOURCE_DIR}/include/libfork/version.hpp)
99

1010
project(
1111
libfork
@@ -19,20 +19,52 @@ project(
1919
# TODO: set property per target
2020
set(CMAKE_CXX_MODULE_STD 1)
2121

22-
# Make a library.
23-
add_library(uses_std STATIC)
22+
# ---- System dependencies ----
2423

25-
# Add sources.
26-
target_sources(uses_std PRIVATE uses_std.cxx)
24+
find_package(Threads REQUIRED)
25+
26+
# ===========================
27+
28+
add_library(libfork_libfork)
29+
add_library(libfork::libfork ALIAS libfork_libfork)
30+
31+
# target_link_libraries(libfork_libfork PRIVATE Threads::Threads)
32+
33+
set_property(TARGET libfork_libfork PROPERTY EXPORT_NAME libfork)
34+
35+
target_compile_features(libfork_libfork PUBLIC cxx_std_23)
36+
37+
# Public headers
38+
target_sources(libfork_libfork
39+
PUBLIC
40+
FILE_SET HEADERS FILES
41+
include/libfork/version.hpp
42+
BASE_DIRS
43+
include
44+
)
45+
46+
# Add the module files to the library, must be public because
47+
# consumers will need bo build the BMI
48+
target_sources(libfork_libfork
49+
PUBLIC
50+
FILE_SET CXX_MODULES FILES
51+
src/libfork.cxx
52+
PRIVATE
53+
src/libfork.cpp
54+
)
55+
56+
# ======================
57+
58+
# TODO: gate below this point behind a dev mode
59+
60+
include(CTest) # Enables the BUILD_TESTING option
61+
62+
if(BUILD_TESTING)
63+
add_subdirectory(test)
64+
endif()
2765

28-
# Tell CMake we're using C++23 but only C++20 is needed to consume it.
29-
target_compile_features(uses_std INTERFACE cxx_std_23)
3066

31-
# Make an executable.
32-
add_executable(main)
3367

34-
target_sources(main PRIVATE main.cxx)
35-
target_link_libraries(main PRIVATE uses_std)
3668

3769
# list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
3870
#
@@ -43,9 +75,6 @@ target_link_libraries(main PRIVATE uses_std)
4375
#
4476
# message(STATUS "CMAKE_BUILD_TYPE is set to '${CMAKE_BUILD_TYPE}'")
4577
#
46-
# # ---- System dependencies ----
47-
#
48-
# find_package(Threads REQUIRED)
4978
#
5079
# # ------ Declare library ------
5180
#

CMakePresets.json

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
{
2+
"version": 10,
3+
"configurePresets": [
4+
{
5+
"name": "llvm-brew",
6+
"displayName": "LLVM (Homebrew)",
7+
"description": "Use Homebrew LLVM compilers",
8+
"binaryDir": "${sourceDir}/build/llvm-brew",
9+
"generator": "Ninja",
10+
"toolchainFile": "${sourceDir}/cmake/llvm-brew-toolchain.cmake",
11+
"cacheVariables": {
12+
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
13+
}
14+
},
15+
{
16+
"name": "gcc-brew",
17+
"displayName": "GCC (Homebrew)",
18+
"description": "Use Homebrew GCC compilers",
19+
"binaryDir": "${sourceDir}/build/gcc-brew",
20+
"generator": "Ninja",
21+
"toolchainFile": "${sourceDir}/cmake/gcc-brew-toolchain.cmake",
22+
"cacheVariables": {
23+
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
24+
}
25+
}
26+
],
27+
"buildPresets": [
28+
{
29+
"name": "llvm-brew",
30+
"configurePreset": "llvm-brew"
31+
},
32+
{
33+
"name": "gcc-brew",
34+
"configurePreset": "gcc-brew"
35+
}
36+
],
37+
"testPresets": [
38+
{
39+
"name": "llvm-brew",
40+
"configurePreset": "llvm-brew",
41+
"output": {
42+
"outputOnFailure": true
43+
},
44+
"execution": {
45+
"stopOnFailure": true
46+
}
47+
},
48+
{
49+
"name": "gcc-brew",
50+
"configurePreset": "gcc-brew",
51+
"output": {
52+
"outputOnFailure": true
53+
},
54+
"execution": {
55+
"stopOnFailure": true
56+
}
57+
}
58+
],
59+
"workflowPresets": [
60+
{
61+
"name": "llvm-brew",
62+
"displayName": "LLVM (Homebrew) Workflow",
63+
"description": "Configure and build using Homebrew LLVM",
64+
"steps": [
65+
{
66+
"type": "configure",
67+
"name": "llvm-brew"
68+
},
69+
{
70+
"type": "build",
71+
"name": "llvm-brew"
72+
},
73+
{
74+
"type": "test",
75+
"name": "llvm-brew"
76+
}
77+
]
78+
},
79+
{
80+
"name": "gcc-brew",
81+
"displayName": "GCC (Homebrew) Workflow",
82+
"description": "Configure and build using Homebrew GCC",
83+
"steps": [
84+
{
85+
"type": "configure",
86+
"name": "gcc-brew"
87+
},
88+
{
89+
"type": "build",
90+
"name": "gcc-brew"
91+
},
92+
{
93+
"type": "test",
94+
"name": "gcc-brew"
95+
}
96+
]
97+
}
98+
]
99+
}

actions/setup/action.yaml

Lines changed: 0 additions & 52 deletions
This file was deleted.

cmake/gcc-brew-toolchain.cmake

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
cmake_minimum_required(VERSION 4.2.1)
2+
3+
# Set up Homebrew GCC@15 toolchain for CMake
4+
5+
find_program(BREW_EXE brew)
6+
7+
if(NOT BREW_EXE)
8+
message(FATAL_ERROR "Could not find 'brew' executable. Please install Homebrew.")
9+
endif()
10+
11+
# Get Ninja prefix
12+
execute_process(
13+
COMMAND ${BREW_EXE} --prefix ninja
14+
OUTPUT_VARIABLE NINJA_PREFIX
15+
OUTPUT_STRIP_TRAILING_WHITESPACE
16+
COMMAND_ERROR_IS_FATAL ANY
17+
)
18+
19+
find_program(CMAKE_MAKE_PROGRAM
20+
NAMES ninja
21+
HINTS "${NINJA_PREFIX}/bin"
22+
NO_DEFAULT_PATH
23+
)
24+
25+
# Get GCC prefix
26+
execute_process(
27+
COMMAND ${BREW_EXE} --prefix gcc
28+
OUTPUT_VARIABLE GCC_PREFIX
29+
OUTPUT_STRIP_TRAILING_WHITESPACE
30+
COMMAND_ERROR_IS_FATAL ANY
31+
)
32+
33+
find_program(CMAKE_C_COMPILER
34+
NAMES gcc-15
35+
HINTS "${GCC_PREFIX}/bin"
36+
NO_DEFAULT_PATH
37+
)
38+
39+
find_program(CMAKE_CXX_COMPILER
40+
NAMES g++-15
41+
HINTS "${GCC_PREFIX}/bin"
42+
NO_DEFAULT_PATH
43+
)
44+
45+
if(NOT CMAKE_C_COMPILER)
46+
message(FATAL_ERROR "Could not find gcc executable in ${GCC_PREFIX}/bin")
47+
endif()
48+
49+
if(NOT CMAKE_CXX_COMPILER)
50+
message(FATAL_ERROR "Could not find g++ executable in ${GCC_PREFIX}/bin")
51+
endif()
52+
53+
# Get macOS SDK path (only on macOS)
54+
if(APPLE)
55+
execute_process(
56+
COMMAND xcrun --show-sdk-path
57+
OUTPUT_VARIABLE CMAKE_OSX_SYSROOT
58+
OUTPUT_STRIP_TRAILING_WHITESPACE
59+
COMMAND_ERROR_IS_FATAL ANY
60+
)
61+
endif()

0 commit comments

Comments
 (0)