This repository has been archived by the owner on Jan 22, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a87e835
Showing
29 changed files
with
382 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: CMake on multiple platforms | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
fail-fast: false | ||
|
||
matrix: | ||
os: [ ubuntu-latest, windows-latest ] | ||
build_type: [ Release, Debug ] | ||
c_compiler: [ gcc, clang, cl ] | ||
include: | ||
- os: windows-latest | ||
c_compiler: cl | ||
cpp_compiler: cl | ||
- os: ubuntu-latest | ||
c_compiler: gcc | ||
cpp_compiler: g++ | ||
- os: ubuntu-latest | ||
c_compiler: clang | ||
cpp_compiler: clang++ | ||
exclude: | ||
- os: windows-latest | ||
c_compiler: gcc | ||
- os: windows-latest | ||
c_compiler: clang | ||
- os: ubuntu-latest | ||
c_compiler: cl | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set reusable strings | ||
id: strings | ||
shell: bash | ||
run: | | ||
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" | ||
- name: Configure CMake | ||
run: > | ||
cmake -B ${{ steps.strings.outputs.build-output-dir }} | ||
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} | ||
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} | ||
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} | ||
-DBUILD_TESTING=ON | ||
-S ${{ github.workspace }} | ||
- name: Build | ||
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} | ||
|
||
- name: Test | ||
working-directory: ${{ steps.strings.outputs.build-output-dir }} | ||
run: ctest --build-config ${{ matrix.build_type }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.idea/**/workspace.xml | ||
.idea/**/tasks.xml | ||
.idea/**/usage.statistics.xml | ||
.idea/**/dictionaries | ||
.idea/**/shelf | ||
cmake-build-*/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
|
||
# setup project | ||
set(PROJECT_NAME "vk") | ||
project(${PROJECT_NAME} LANGUAGES CXX) | ||
|
||
# inc all cmake util | ||
include(cmake/all.cmake) | ||
|
||
# add project components | ||
add_libraries_directory(core) | ||
add_executables_directory(tool) | ||
add_tests_directory(test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
C(LEAN)MAKE | ||
=========== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
C(LEAN)MAKE | ||
=========== | ||
|
||
Project skeleton for less verbose CMake scripts. | ||
Creates tree new ```add_directory``` commands that create magic directories. | ||
|
||
```cmake | ||
add_libraries_directory(<dir>) | ||
add_executables_directory(<dir>) | ||
add_tests_directory(<dir>) | ||
``` | ||
|
||
add_libraries_directory(dir) | ||
---------------------------- | ||
|
||
The libraries directory contains only libraries. Each subdirectory with a target.cmake file marks a library root. | ||
A library is either static library or a header only library depending on the presence of a src directory. (src/ -> static_library) | ||
|
||
In the target.cmake file the library target can be configured. The target is already created with the name ```${TARGET_NAME}```. | ||
|
||
add_executables_directory(dir) | ||
------------------------------ | ||
|
||
... | ||
|
||
add_tests_directory(dir) | ||
------------------------ | ||
|
||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
function(add_executables_directory EXECUTABLES_REL_DIR) | ||
|
||
file(GLOB_RECURSE TARGET_PATHS "${EXECUTABLES_REL_DIR}/**/target.cmake") | ||
foreach (TARGET_PATH ${TARGET_PATHS}) | ||
|
||
get_filename_component(TARGET_ABS_PATH "${TARGET_PATH}" ABSOLUTE) | ||
get_filename_component(TARGET_ABS_DIR "${TARGET_ABS_PATH}" DIRECTORY) | ||
file(RELATIVE_PATH TARGET_REL_DIR "${CMAKE_CURRENT_LIST_DIR}/${EXECUTABLES_REL_DIR}" ${TARGET_ABS_DIR}) | ||
|
||
set(TARGET_NAME "${TARGET_REL_DIR}") | ||
|
||
foreach (LOWER_LETTER a b c d e f g h i j k l m n o p q r s t u v w x y z) | ||
string(TOUPPER ${LOWER_LETTER} UPPER_LETTER) | ||
string(REGEX REPLACE "${UPPER_LETTER}" "${LOWER_LETTER}" TARGET_NAME ${TARGET_NAME}) | ||
endforeach () | ||
|
||
string(REPLACE "-" "_" TARGET_NAME ${TARGET_NAME}) | ||
string(REPLACE " " "_" TARGET_NAME ${TARGET_NAME}) | ||
string(REPLACE "/" "_" TARGET_NAME ${TARGET_NAME}) | ||
string(REPLACE "\\" "_" TARGET_NAME ${TARGET_NAME}) | ||
|
||
file(GLOB_RECURSE TARGET_SOURCE | ||
"${TARGET_ABS_DIR}/src/*.hpp" | ||
"${TARGET_ABS_DIR}/src/*.cpp") | ||
|
||
add_executable(${TARGET_NAME}) | ||
target_sources(${TARGET_NAME} PRIVATE ${TARGET_SOURCE}) | ||
|
||
set_target_properties(${TARGET_NAME} PROPERTIES | ||
LINKER_LANGUAGE CXX | ||
CXX_STANDARD 20 | ||
CXX_STANDARD_REQUIRED ON) | ||
|
||
include("${TARGET_ABS_PATH}") | ||
|
||
message("${PROJECT_NAME} - Added Executable ${TARGET_NAME}") | ||
|
||
endforeach () | ||
|
||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
function(add_libraries_directory LIBRARIES_REL_DIR) | ||
|
||
file(GLOB_RECURSE TARGET_PATHS "${LIBRARIES_REL_DIR}/**/target.cmake") | ||
foreach (TARGET_PATH ${TARGET_PATHS}) | ||
|
||
get_filename_component(TARGET_ABS_PATH "${TARGET_PATH}" ABSOLUTE) | ||
get_filename_component(TARGET_ABS_DIR "${TARGET_ABS_PATH}" DIRECTORY) | ||
file(RELATIVE_PATH TARGET_REL_DIR "${CMAKE_CURRENT_LIST_DIR}/${LIBRARIES_REL_DIR}" ${TARGET_ABS_DIR}) | ||
|
||
set(TARGET_NAME "${TARGET_REL_DIR}") | ||
|
||
foreach (LOWER_LETTER a b c d e f g h i j k l m n o p q r s t u v w x y z) | ||
string(TOUPPER ${LOWER_LETTER} UPPER_LETTER) | ||
string(REGEX REPLACE "${UPPER_LETTER}" "${LOWER_LETTER}" TARGET_NAME ${TARGET_NAME}) | ||
endforeach () | ||
|
||
string(REPLACE "-" "_" TARGET_NAME ${TARGET_NAME}) | ||
string(REPLACE " " "_" TARGET_NAME ${TARGET_NAME}) | ||
string(REPLACE "/" "_" TARGET_NAME ${TARGET_NAME}) | ||
string(REPLACE "\\" "_" TARGET_NAME ${TARGET_NAME}) | ||
|
||
file(GLOB_RECURSE TARGET_HEADER | ||
"${TARGET_ABS_DIR}/inc/*.hpp") | ||
|
||
file(GLOB_RECURSE TARGET_SOURCE | ||
"${TARGET_ABS_DIR}/src/*.hpp" | ||
"${TARGET_ABS_DIR}/src/*.cpp") | ||
|
||
if (TARGET_SOURCE) | ||
add_library(${TARGET_NAME} STATIC) | ||
target_sources(${TARGET_NAME} PUBLIC ${TARGET_HEADER}) | ||
target_sources(${TARGET_NAME} PRIVATE ${TARGET_SOURCE}) | ||
else () | ||
add_library(${TARGET_NAME} INTERFACE) | ||
target_sources(${TARGET_NAME} INTERFACE ${TARGET_HEADER}) | ||
endif () | ||
|
||
target_include_directories(${TARGET_NAME} INTERFACE "${TARGET_ABS_DIR}/inc") | ||
|
||
set_target_properties(${TARGET_NAME} PROPERTIES | ||
LINKER_LANGUAGE CXX | ||
CXX_STANDARD 20 | ||
CXX_STANDARD_REQUIRED ON) | ||
|
||
include("${TARGET_ABS_PATH}") | ||
|
||
message("${PROJECT_NAME} - Added Library ${TARGET_NAME}") | ||
|
||
endforeach () | ||
|
||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
if (NOT EXISTS "${PROJECT_SOURCE_DIR}/.venv") | ||
execute_process("python -m venv ${PROJECT_SOURCE_DIR}/.venv") | ||
endif() | ||
|
||
function(add_python_directory PYTHON_REL_DIR) | ||
|
||
file(GLOB_RECURSE TARGET_PATHS "${PYTHON_REL_DIR}/**/target.cmake") | ||
foreach (TARGET_PATH ${TARGET_PATHS}) | ||
|
||
get_filename_component(TARGET_ABS_PATH "${TARGET_PATH}" ABSOLUTE) | ||
get_filename_component(TARGET_ABS_DIR "${TARGET_ABS_PATH}" DIRECTORY) | ||
file(RELATIVE_PATH TARGET_REL_DIR "${CMAKE_CURRENT_LIST_DIR}/${LIBRARIES_REL_DIR}" ${TARGET_ABS_DIR}) | ||
|
||
set(TARGET_NAME "${TARGET_REL_DIR}") | ||
|
||
foreach (LOWER_LETTER a b c d e f g h i j k l m n o p q r s t u v w x y z) | ||
string(TOUPPER ${LOWER_LETTER} UPPER_LETTER) | ||
string(REGEX REPLACE "${UPPER_LETTER}" "${LOWER_LETTER}" TARGET_NAME ${TARGET_NAME}) | ||
endforeach () | ||
|
||
string(REPLACE "-" "_" TARGET_NAME ${TARGET_NAME}) | ||
string(REPLACE " " "_" TARGET_NAME ${TARGET_NAME}) | ||
string(REPLACE "/" "_" TARGET_NAME ${TARGET_NAME}) | ||
string(REPLACE "\\" "_" TARGET_NAME ${TARGET_NAME}) | ||
|
||
# TODO | ||
|
||
set(TARGET_BUILD_PY "${TARGET_ABS_DIR}/src/build.py") | ||
set(TARGET_GENERATE_PY "${TARGET_ABS_DIR}/src/generate.py") | ||
|
||
add_library(${TARGET_NAME} STATIC) | ||
target_sources(${TARGET_NAME} PUBLIC ${TARGET_HEADER}) | ||
|
||
target_include_directories(${TARGET_NAME} INTERFACE "${TARGET_ABS_DIR}/inc") | ||
|
||
set_target_properties(${TARGET_NAME} PROPERTIES | ||
LINKER_LANGUAGE CXX | ||
CXX_STANDARD 20 | ||
CXX_STANDARD_REQUIRED ON) | ||
|
||
include("${TARGET_ABS_PATH}") | ||
|
||
endforeach() | ||
|
||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
option(BUILD_TESTING "Build Tests" OFF) | ||
if (BUILD_TESTING) | ||
enable_testing() | ||
endif () | ||
|
||
function(add_tests_directory TESTS_REL_DIR) | ||
|
||
if (BUILD_TESTING) | ||
|
||
get_filename_component(TESTS_ABS_PATH "${TESTS_REL_DIR}" ABSOLUTE) | ||
|
||
file(GLOB_RECURSE TARGET_PATHS "${TESTS_REL_DIR}/*.cpp") | ||
foreach (TARGET_PATH ${TARGET_PATHS}) | ||
|
||
get_filename_component(TARGET_ABS_PATH "${TARGET_PATH}" ABSOLUTE) | ||
get_filename_component(TARGET_ABS_DIR "${TARGET_ABS_PATH}" DIRECTORY) | ||
file(RELATIVE_PATH TARGET_REL_DIR "${TESTS_ABS_PATH}" ${TARGET_ABS_DIR}) | ||
|
||
get_filename_component(TARGET_NAME "${TARGET_PATH}" NAME_WE) | ||
set(TARGET_NAME "test_${TARGET_REL_DIR}_${TARGET_NAME}") | ||
|
||
foreach (LOWER_LETTER a b c d e f g h i j k l m n o p q r s t u v w x y z) | ||
string(TOUPPER ${LOWER_LETTER} UPPER_LETTER) | ||
string(REGEX REPLACE "${UPPER_LETTER}" "${LOWER_LETTER}" TARGET_NAME ${TARGET_NAME}) | ||
endforeach () | ||
|
||
string(REPLACE "." "_" TARGET_NAME ${TARGET_NAME}) | ||
string(REPLACE "-" "_" TARGET_NAME ${TARGET_NAME}) | ||
string(REPLACE " " "_" TARGET_NAME ${TARGET_NAME}) | ||
string(REPLACE "/" "_" TARGET_NAME ${TARGET_NAME}) | ||
string(REPLACE "\\" "_" TARGET_NAME ${TARGET_NAME}) | ||
|
||
add_executable(${TARGET_NAME} "${TARGET_ABS_PATH}") | ||
set_target_properties(${TARGET_NAME} PROPERTIES | ||
LINKER_LANGUAGE CXX | ||
CXX_STANDARD 20 | ||
CXX_STANDARD_REQUIRED ON) | ||
|
||
set(TARGET_REL_DIR_PART ${TARGET_REL_DIR}) | ||
while (TARGET_REL_DIR_PART) | ||
|
||
file(GLOB TARGET_CONFIG_PATH "${TESTS_ABS_PATH}/${TARGET_REL_DIR_PART}/config.cmake") | ||
if (TARGET_CONFIG_PATH) | ||
include(${TARGET_CONFIG_PATH}) | ||
endif () | ||
|
||
get_filename_component(TARGET_REL_DIR_PART "${TARGET_REL_DIR_PART}" DIRECTORY) | ||
endwhile () | ||
|
||
add_test(NAME "${TARGET_NAME}" COMMAND $<TARGET_FILE:${TARGET_NAME}>) | ||
|
||
message("${PROJECT_NAME} - Added Test ${TARGET_NAME}") | ||
|
||
endforeach () | ||
|
||
endif () | ||
|
||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
message("${PROJECT_NAME} - Added CMake Script all.cmake") | ||
|
||
# inc all cmake files from the cmake directory | ||
file(GLOB_RECURSE INCLUDES "cmake/*.cmake") | ||
foreach (INCLUDE ${INCLUDES}) | ||
get_filename_component(INCLUDE_NAME "${INCLUDE}" NAME) | ||
if (NOT INCLUDE_NAME STREQUAL "all.cmake") | ||
include(${INCLUDE}) | ||
message("${PROJECT_NAME} - Added CMake Script ${INCLUDE_NAME}") | ||
endif () | ||
endforeach () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
set(_IGNORE_CMAKE_C_COMPILER "${CMAKE_C_COMPILER}") | ||
|
||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_CXX_STANDARD 20) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") | ||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") | ||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#ifndef SAMPLE_HPP | ||
#define SAMPLE_HPP | ||
|
||
namespace w { | ||
|
||
class SceneGraph { | ||
public: | ||
}; | ||
|
||
} | ||
|
||
#endif |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#ifndef TEST_UTIL_HPP | ||
#define TEST_UTIL_HPP | ||
|
||
#include <cstdlib> | ||
|
||
inline void trivial_assert(bool condition) { | ||
if (!condition) { | ||
std::exit(1); | ||
} | ||
} | ||
|
||
#endif |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
target_link_libraries(${TARGET_NAME} PRIVATE test_util scenegraph) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include <sample/sample.hpp> | ||
#include <test_util.hpp> | ||
|
||
int main() { | ||
} |
Oops, something went wrong.