Skip to content

build: add windows build #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 24 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
needs: [pre-commit, cppcheck]
runs-on: ubuntu-latest
strategy:
fail-fast: true
fail-fast: false
matrix:
include:
- cpp-version: gcc-9
Expand All @@ -91,11 +91,6 @@ jobs:
package: "gcc-12 g++-12"
cc: "gcc-12"
cxx: "g++-12"
- cpp-version: clang-11
compiler: "clang"
package: "clang-11"
cc: "clang-11"
cxx: "clang++-11"
- cpp-version: clang-12
compiler: "clang"
package: "clang-12"
Expand Down Expand Up @@ -175,9 +170,15 @@ jobs:
cd build
./test/test_scopi

macos-mamba:
needs: [pre-commit, cppcheck]
runs-on: macos-14
mamba-build:
# needs: [pre-commit, cppcheck]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- macos-14
# - windows-2022
steps:
- uses: actions/checkout@v4
- name: Mamba and scopi env installation
Expand All @@ -187,18 +188,14 @@ jobs:
environment-name: scopi-env
cache-environment: true

- name: Installl cxx compiler
shell: bash -l {0}
run: |
micromamba install -y cxx-compiler

- name: micromamba informations
shell: bash -l {0}
run: |
micromamba info
micromamba list

- name: Configure
if: runner.os == 'Macos'
shell: bash -l {0}
run: |
cmake \
Expand All @@ -209,10 +206,22 @@ jobs:
-DBUILD_EXAMPLES=ON \
-DBUILD_TESTS=ON

# - name: Configure
# if: runner.os == 'Windows'
# shell: bash -l {0}
# run: |
# cmake \
# . \
# -Bbuild \
# -G "Visual Studio 17 2022" \
# -DCMAKE_BUILD_TYPE=Release \
# -DBUILD_EXAMPLES=ON \
# -DBUILD_TESTS=ON

- name: Build
shell: bash -l {0}
run: |
cmake --build ./build --config Release --parallel 3
cmake --build ./build --config Release

- name: Run tests
shell: bash -l {0}
Expand Down
208 changes: 93 additions & 115 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,99 +1,69 @@
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.20)

project(scopi)
include(FetchContent)
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
cmake_policy(SET CMP0135 NEW)
endif()

# Flags
# ===========
# Add project_options from https://github.com/aminya/project_options
# Change the version in the following URL to update the package (watch the releases of the repository for future updates)
set(PROJECT_OPTIONS_VERSION "v0.35.1")
FetchContent_Declare(
_project_options
URL https://github.com/aminya/project_options/archive/refs/tags/${PROJECT_OPTIONS_VERSION}.zip)
FetchContent_MakeAvailable(_project_options)
include(${_project_options_SOURCE_DIR}/Index.cmake)

# set(CMAKE_SKIP_BUILD_RPATH FALSE)
# set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)

# set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
# set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic ")
set(CMAKE_CXX_STANDARD 17)
message(STATUS "CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}")
# Set version
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/version.txt")
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/version.txt" SCOPI_VERSION)
string(STRIP "${SCOPI_VERSION}" SCOPI_VERSION)
else()
message(FATAL_ERROR "File ${CMAKE_CURRENT_SOURCE_DIR}/version.txt not found")
endif()

project(scopi VERSION ${SCOPI_VERSION} LANGUAGES CXX)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
set(SCOPI_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)

# Versionning
# ===========
include(version)
set_version()
project_options(
PREFIX "scopi"
ENABLE_VS_ANALYSIS
)

# Options
# =======
OPTION(SCOPI_USE_TBB "enable TBB" OFF)
OPTION(SCOPI_USE_OPENMP "enable OpenMP" OFF)
OPTION(SCOPI_USE_MOSEK "enable Mosek" OFF)
OPTION(SCOPI_USE_SCS "enable SCS" OFF)
OPTION(BUILD_EXAMPLES "scopi examples" OFF)
OPTION(BUILD_TESTS "scopi test suite" OFF)

if(SCOPI_USE_TBB AND SCOPI_USE_OPENMP)
message(
FATAL
"SCOPI_USE_TBB and SCOPI_USE_OPENMP cannot both be active at once"
)
endif()
)
endif()

# Dependencies
# ============
if(SCOPI_USE_TBB)
set(XTENSOR_USE_TBB 1)
endif()

find_package(xtensor REQUIRED)
find_package(nlohmann_json REQUIRED)
find_package(fmt REQUIRED)
find_package(CLI11 REQUIRED)

find_package(plog REQUIRED)
find_package(nanoflann REQUIRED)
# set(DEPENDENCIES_CONFIGURED xtensor xtensor-blas nlohmann_json fmt CLI11 plog nanoflann)

# section needed to use xtensor-blas
# see https://xtensor-blas.readthedocs.io/en/latest/performance.html
add_definitions(-DHAVE_CBLAS=1)
# if(SCOPI_USE_TBB)
# set(XTENSOR_USE_TBB 1)
# append(DEPENDENCIES_CONFIGURED TBB)
# endif()

if(WIN32)
find_package(OpenBLAS REQUIRED)
set(BLAS_LIBRARIES ${CMAKE_INSTALL_PREFIX}${OpenBLAS_LIBRARIES})
else()
find_package(BLAS REQUIRED)
find_package(LAPACK REQUIRED)
endif()

message(STATUS "BLAS VENDOR: " ${BLA_VENDOR})
message(STATUS "BLAS LIBRARIES: " ${BLAS_LIBRARIES})

# end of xtensor-blas section
if(SCOPI_USE_TBB)
find_package(TBB REQUIRED)
endif()
# if(SCOPI_USE_OPENMP)
# append(DEPENDENCIES_CONFIGURED OpenMP)
# endif()

if(SCOPI_USE_OPENMP)
find_package(OpenMP REQUIRED)
endif()

if(SCOPI_USE_MOSEK)
find_package(MOSEK REQUIRED)

if(APPLE)
set(MOSEK_FUSION_LIBRARY "" CACHE FILEPATH "MOSEK FUSION LIBRARY")
endif(APPLE)
endif()

if(SCOPI_USE_SCS)
find_package(scs REQUIRED)
endif()

# Package
# =======
set(CMAKE_NO_SYSTEM_FROM_IMPORTED TRUE)
# foreach(DEPENDENCY ${DEPENDENCIES_CONFIGURED})
# find_package(${DEPENDENCY} REQUIRED)
# endforeach()

set(SCOPI_SRC
src/vap/vap_fixed.cpp
src/vap/vap_fpd.cpp
src/vap/vap_projection.cpp
src/minpack.cpp
Expand All @@ -102,52 +72,59 @@ set(SCOPI_SRC
src/utils.cpp
)

add_library(scopi ${SCOPI_SRC})

target_include_directories(scopi PUBLIC
$<BUILD_INTERFACE:${SCOPI_INCLUDE_DIR}>
$<INSTALL_INTERFACE:include>)
add_library(libscopi ${SCOPI_SRC})

target_link_libraries(scopi PUBLIC xtensor
nlohmann_json::nlohmann_json
fmt::fmt
CLI11::CLI11

plog::plog
nanoflann::nanoflann
${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})

# set_target_properties(scopi PROPERTIES
# PUBLIC_HEADER "${SCOPI_HEADERS}"
# # COMPILE_DEFINITIONS "SCOPI_EXPORTS"
# PREFIX ""
# VERSION ${${PROJECT_NAME}_VERSION}
# SOVERSION ${VERSION_MAJOR}
# OUTPUT_NAME "libscopi")

if(SCOPI_USE_TBB)
target_link_libraries(scopi PUBLIC TBB::tbb)
target_compile_definitions(scopi PUBLIC SCOPI_USE_TBB)
endif()
# link project_options/warnings
target_link_libraries(libscopi
PRIVATE scopi_project_options scopi_project_warnings
)

if(SCOPI_USE_OPENMP)
target_link_libraries(scopi PUBLIC OpenMP::OpenMP_CXX)
target_compile_definitions(scopi PUBLIC SCOPI_USE_OPENMP)
endif()
# Includes:
target_include_interface_directories(libscopi "${CMAKE_CURRENT_SOURCE_DIR}/include")

# Find dependencies:
target_find_dependencies(libscopi
PRIVATE_CONFIG
xtensor
xtensor-blas
nlohmann_json
fmt
CLI11
plog
nanoflann
)

if(SCOPI_USE_MOSEK)
include_directories(SYSTEM ${MOSEK_INCLUDE_DIR})
target_link_libraries(scopi LINK_PUBLIC ${MOSEK_LIBRARIES})
target_include_directories(scopi PUBLIC ${MOSEK_INCLUDE_DIR})
target_compile_definitions(scopi PUBLIC SCOPI_USE_MOSEK)
endif()
# Link dependencies:
target_link_system_libraries(libscopi
PRIVATE
xtensor
xtensor-blas
nlohmann_json::nlohmann_json
fmt::fmt
CLI11::CLI11
plog::plog
nanoflann::nanoflann
)

if(SCOPI_USE_SCS)
include_directories(SYSTEM ${scs_INCLUDE_DIR})
target_link_libraries(scopi PUBLIC ${scs_LIBRARIES})
target_include_directories(scopi PUBLIC ${scs_INCLUDE_DIR})
target_compile_definitions(scopi PUBLIC SCOPI_USE_SCS)
endif()
# target_link_libraries(scopi PUBLIC
# xtensor
# xtensor-blas
# nlohmann_json::nlohmann_json
# fmt::fmt
# CLI11::CLI11
# plog::plog
# nanoflann::nanoflann
# )

# if(SCOPI_USE_TBB)
# target_link_libraries(scopi PUBLIC TBB::tbb)
# target_compile_definitions(scopi PUBLIC SCOPI_USE_TBB)
# endif()

# if(SCOPI_USE_OPENMP)
# target_link_libraries(scopi PUBLIC OpenMP::OpenMP_CXX)
# target_compile_definitions(scopi PUBLIC SCOPI_USE_OPENMP)
# endif()

if(BUILD_EXAMPLES)
add_subdirectory(demos)
Expand All @@ -159,7 +136,8 @@ if(BUILD_TESTS)
add_subdirectory(test)
endif()

# Installation
# ============
include(installation)
install_project()
# Package the project
package_project(
TARGETS libscopi
scopi_project_options scopi_project_warnings
)
11 changes: 0 additions & 11 deletions cmake/addGoogleTest.cmake

This file was deleted.

12 changes: 1 addition & 11 deletions cmake/generator.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,6 @@ function (generate_executable)
foreach(filename IN LISTS ARGN)
string(REPLACE ".cpp" "" targetname ${filename})
add_executable(${targetname} ${filename})
target_link_libraries(${targetname} scopi)

# if (APPLE)
# add_custom_command(TARGET critical_2d
# POST_BUILD COMMAND
# ${CMAKE_INSTALL_NAME_TOOL} -change
# `otool -L critical_2d | sed -n -e \""s/.*\\(libmosek.*dylib\\).*/\\1/p"\"`
# ${MOSEK_LIBRARY} critical_2d
# )
# endif(APPLE)

target_link_libraries(${targetname} libscopi)
endforeach()
endfunction()
4 changes: 2 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ foreach(filename IN LISTS SCOPI_TESTS)
add_executable(${targetname} ${COMMON_BASE} ${filename} ${SCOPI_HEADERS})
target_include_directories(${targetname} PRIVATE ${SCOPI_INCLUDE_DIR})
target_compile_features(${targetname} PRIVATE cxx_std_17)
target_link_libraries(${targetname} scopi doctest::doctest)
target_link_libraries(${targetname} libscopi doctest::doctest)
endforeach()

add_executable(test_scopi ${COMMON_BASE} ${SCOPI_TESTS})
target_include_directories(test_scopi PRIVATE ${SCOPI_INCLUDE_DIR})
target_compile_features(test_scopi PRIVATE cxx_std_17)
target_link_libraries(test_scopi PRIVATE scopi doctest::doctest)
target_link_libraries(test_scopi PRIVATE libscopi doctest::doctest)
Loading