-
-
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.
Merge pull request #9 from terasakisatoshi/terasaki/omikuji
Terasaki/omikuji
- Loading branch information
Showing
11 changed files
with
166 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,46 @@ | ||
# This starter workflow is for a CMake project running on a single platform. There is a different starter workflow if you need cross-platform coverage. | ||
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml | ||
name: omikuji | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
paths: | ||
- "./omikuji/*" | ||
- ".github/workflows/omikuji.yml" | ||
|
||
env: | ||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) | ||
BUILD_TYPE: Release | ||
|
||
defaults: | ||
run: | ||
working-directory: ./omikuji | ||
|
||
jobs: | ||
build: | ||
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. | ||
# You can convert this to a matrix build if you need cross-platform coverage. | ||
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Configure CMake | ||
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. | ||
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type | ||
run: cmake -S . -B ./build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} | ||
|
||
- name: Build | ||
# Build your program with the given configuration | ||
run: cmake --build ./build --config ${{env.BUILD_TYPE}} | ||
|
||
- name: Install | ||
run: cmake --install ./build --prefix ./goma | ||
|
||
- name: Test | ||
working-directory: ${{github.workspace}}/omikuji/app | ||
run: bash build.sh && ${{github.workspace}}/omikuji/app/build/main |
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 |
---|---|---|
|
@@ -32,3 +32,4 @@ | |
*.app | ||
|
||
**/build | ||
.DS_Store |
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,63 @@ | ||
cmake_minimum_required(VERSION 3.20) | ||
|
||
project(Omikuji VERSION 0.1.0) | ||
|
||
option(BUILD_SHARED_LIBS "Build using shared libraries" ON) | ||
|
||
if(APPLE) | ||
set(CMAKE_INSTALL_RPATH "@executable_path/../lib") | ||
elseif(UNIX) | ||
set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib") | ||
endif() | ||
|
||
# libraries | ||
add_library(${PROJECT_NAME}_compiler_flags INTERFACE) | ||
target_compile_features(${PROJECT_NAME}_compiler_flags INTERFACE cxx_std_11) | ||
add_subdirectory(src) | ||
# applications | ||
# add_subdirectory(app) | ||
|
||
# installation | ||
|
||
# setup installer | ||
include(InstallRequiredSystemLibraries) | ||
# set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt") | ||
set(CPACK_PACKAGE_VERSION_MAJOR "${${PROJECT_NAME}_VERSION_MAJOR}") | ||
set(CPACK_PACKAGE_VERSION_MINOR "${${PROJECT_NAME}_VERSION_MINOR}") | ||
set(CPACK_SOURCE_GENERATOR "TGZ") | ||
include(CPack) | ||
|
||
install(EXPORT ${PROJECT_NAME}Targets | ||
FILE ${PROJECT_NAME}Targets.cmake | ||
NAMESPACE Omikuji:: | ||
DESTINATION lib/cmake/${PROJECT_NAME} | ||
) | ||
|
||
include(CMakePackageConfigHelpers) | ||
# generate the config file that is includes the exports | ||
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in | ||
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" | ||
INSTALL_DESTINATION "lib/cmake/${PROJECT_NAME}" | ||
NO_SET_AND_CHECK_MACRO | ||
NO_CHECK_REQUIRED_COMPONENTS_MACRO | ||
) | ||
|
||
# generate the version file for the config file | ||
write_basic_package_version_file( | ||
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" | ||
VERSION "${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}" | ||
COMPATIBILITY AnyNewerVersion | ||
) | ||
|
||
# install the configuration file | ||
install(FILES | ||
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake | ||
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake | ||
DESTINATION lib/cmake/${PROJECT_NAME} | ||
) | ||
|
||
# generate the export targets for the build tree | ||
# needs to be after the install(TARGETS ) command | ||
export(EXPORT ${PROJECT_NAME}Targets | ||
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake" | ||
) |
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 @@ | ||
@PACKAGE_INIT@ | ||
|
||
include ( "${CMAKE_CURRENT_LIST_DIR}/OmikujiTargets.cmake" ) |
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 @@ | ||
find_package(Omikuji REQUIRED) | ||
|
||
add_executable(main main.cpp) | ||
target_link_libraries(main Omikuji::drawing) |
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 @@ | ||
rm -rf ./build | ||
cmake -S . -B ./build -DCMAKE_PREFIX_PATH=../goma | ||
cmake --build ./build |
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,7 @@ | ||
#include<iostream> | ||
#include "drawing.hpp" | ||
|
||
int main(){ | ||
std::cout << draw() << std::endl; | ||
return 0; | ||
} |
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 @@ | ||
rm -rf build ${PWD}/goma | ||
cmake -S . -B ./build | ||
cmake --build ./build --config=Release | ||
cmake --install ./build --prefix=${PWD}/goma |
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,18 @@ | ||
add_library(drawing drawing.cpp) | ||
|
||
target_include_directories(drawing | ||
INTERFACE | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> | ||
$<INSTALL_INTERFACE:include> | ||
) | ||
target_link_libraries(drawing PUBLIC ${PROJECT_NAME}_compiler_flags) | ||
|
||
set_property(TARGET drawing PROPERTY VERSION "0.1.0") | ||
set_property(TARGET drawing PROPERTY SOVERSION "0.1.0") | ||
|
||
set(installable_libs drawing ${PROJECT_NAME}_compiler_flags) | ||
install(TARGETS ${installable_libs} | ||
EXPORT ${PROJECT_NAME}Targets | ||
DESTINATION lib) | ||
|
||
install(FILES drawing.hpp DESTINATION include) |
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 @@ | ||
#include<string> | ||
#include<random> | ||
#include "drawing.hpp" | ||
|
||
std::string draw(){ | ||
std::random_device seed_gen; | ||
std::mt19937 rng(seed_gen()); | ||
|
||
std::vector<std::string> slips = {"Very good luck", "Good luck", "Bad luck", "Extremely bad luck"}; | ||
std::uniform_int_distribution<> dist_n(0, slips.size()-1); | ||
int n = dist_n(rng); | ||
return slips[n]; | ||
} |
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 @@ | ||
#include<string> | ||
#pragma once | ||
|
||
std::string draw(); |