feat: cmake improvements and simple ci (#9)
* move main and stb-libs to subfolder * cmake : general additions * ci : add simple building --------- Co-authored-by: leejet <31925346+leejet@users.noreply.github.com>
This commit is contained in:
parent
8f34dd7cc7
commit
844351c417
98
.github/workflows/build.yml
vendored
Normal file
98
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
paths: ['.github/workflows/**', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu']
|
||||||
|
pull_request:
|
||||||
|
types: [opened, synchronize, reopened]
|
||||||
|
paths: ['**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu']
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ubuntu-latest-cmake:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Clone
|
||||||
|
id: checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
|
||||||
|
- name: Dependencies
|
||||||
|
id: depends
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install build-essential
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
id: cmake_build
|
||||||
|
run: |
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake ..
|
||||||
|
cmake --build . --config Release
|
||||||
|
|
||||||
|
#- name: Test
|
||||||
|
#id: cmake_test
|
||||||
|
#run: |
|
||||||
|
#cd build
|
||||||
|
#ctest --verbose --timeout 900
|
||||||
|
|
||||||
|
macOS-latest-cmake:
|
||||||
|
runs-on: macos-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Clone
|
||||||
|
id: checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Dependencies
|
||||||
|
id: depends
|
||||||
|
continue-on-error: true
|
||||||
|
run: |
|
||||||
|
brew update
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
id: cmake_build
|
||||||
|
run: |
|
||||||
|
sysctl -a
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake ..
|
||||||
|
cmake --build . --config Release
|
||||||
|
|
||||||
|
#- name: Test
|
||||||
|
#id: cmake_test
|
||||||
|
#run: |
|
||||||
|
#cd build
|
||||||
|
#ctest --verbose --timeout 900
|
||||||
|
|
||||||
|
windows-latest-cmake:
|
||||||
|
runs-on: windows-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Clone
|
||||||
|
id: checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
id: cmake_build
|
||||||
|
run: |
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake ..
|
||||||
|
cmake --build . --config Release
|
||||||
|
|
||||||
|
#- name: Test
|
||||||
|
#id: cmake_test
|
||||||
|
#run: |
|
||||||
|
#cd build
|
||||||
|
#ctest -C Release --verbose --timeout 900
|
||||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@ build*/
|
|||||||
test/
|
test/
|
||||||
|
|
||||||
.cache/
|
.cache/
|
||||||
|
*.swp
|
||||||
|
@ -1,16 +1,44 @@
|
|||||||
cmake_minimum_required(VERSION 3.12)
|
cmake_minimum_required(VERSION 3.12)
|
||||||
project(stable-diffusion)
|
project("stable-diffusion")
|
||||||
|
|
||||||
set(SD_LIB stable-diffusion)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
set(SD_TARGET sd)
|
|
||||||
|
|
||||||
|
if (NOT XCODE AND NOT MSVC AND NOT CMAKE_BUILD_TYPE)
|
||||||
|
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
|
||||||
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||||
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||||
|
|
||||||
|
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||||
|
set(SD_STANDALONE ON)
|
||||||
|
else()
|
||||||
|
set(SD_STANDALONE OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#
|
||||||
|
# Option list
|
||||||
|
#
|
||||||
|
|
||||||
|
# general
|
||||||
|
#option(SD_BUILD_TESTS "sd: build tests" ${SD_STANDALONE})
|
||||||
|
option(SD_BUILD_EXAMPLES "sd: build examples" ${SD_STANDALONE})
|
||||||
|
#option(SD_BUILD_SERVER "sd: build server example" ON)
|
||||||
|
|
||||||
|
|
||||||
|
# deps
|
||||||
add_subdirectory(ggml)
|
add_subdirectory(ggml)
|
||||||
|
|
||||||
|
set(SD_LIB stable-diffusion)
|
||||||
|
|
||||||
add_library(${SD_LIB} stable-diffusion.h stable-diffusion.cpp)
|
add_library(${SD_LIB} stable-diffusion.h stable-diffusion.cpp)
|
||||||
add_executable(${SD_TARGET} main.cpp stb_image.h stb_image_write.h)
|
|
||||||
|
|
||||||
target_link_libraries(${SD_LIB} PUBLIC ggml)
|
target_link_libraries(${SD_LIB} PUBLIC ggml)
|
||||||
target_link_libraries(${SD_TARGET} ${SD_LIB})
|
target_include_directories(${SD_LIB} PUBLIC .)
|
||||||
|
|
||||||
target_compile_features(${SD_LIB} PUBLIC cxx_std_11)
|
target_compile_features(${SD_LIB} PUBLIC cxx_std_11)
|
||||||
target_compile_features(${SD_TARGET} PUBLIC cxx_std_11)
|
|
||||||
|
|
||||||
|
if (SD_BUILD_EXAMPLES)
|
||||||
|
add_subdirectory(examples)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
8
examples/CMakeLists.txt
Normal file
8
examples/CMakeLists.txt
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# TODO: move into its own subdirectoy
|
||||||
|
# TODO: make stb libs a target (maybe common)
|
||||||
|
set(SD_TARGET sd)
|
||||||
|
|
||||||
|
add_executable(${SD_TARGET} main.cpp stb_image.h stb_image_write.h)
|
||||||
|
install(TARGETS ${SD_TARGET} RUNTIME)
|
||||||
|
target_link_libraries(${SD_TARGET} PRIVATE stable-diffusion ${CMAKE_THREAD_LIBS_INIT})
|
||||||
|
target_compile_features(${SD_TARGET} PUBLIC cxx_std_11)
|
Loading…
Reference in New Issue
Block a user