Skip to content

Commit

Permalink
Merge pull request #7 from csdms/mdpiper/update-cmake-build
Browse files Browse the repository at this point in the history
Update CMake build
  • Loading branch information
mdpiper committed Oct 19, 2023
2 parents 88cf8e7 + 375bb56 commit aabb8e8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
9 changes: 5 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.12)

project(bmic C)
project(bmic LANGUAGES C)

set(BMI_VERSION 2.0)
include(GNUInstallDirs)

configure_file(${CMAKE_SOURCE_DIR}/${CMAKE_PROJECT_NAME}.pc.cmake
${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}.pc)

install(
FILES bmi.h
DESTINATION include
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(
FILES ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}.pc
DESTINATION lib/pkgconfig
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ into an Anaconda distribution with

### Linux and macOS

To install the C BMI bindings from source with cmake, run
To install the C BMI bindings from source with CMake, run

mkdir _build && cd _build
cmake .. -DCMAKE_INSTALL_PREFIX=<path-to-installation>
make install

where `<path-to-installation>` is the base directory
in which to install the bindings (`/usr/local` is the default).
When using a conda environment,
use the `$CONDA_PREFIX` environment variable.

The installation will look like:

Expand All @@ -54,7 +56,7 @@ An additional prerequisite is needed for Windows:

* Microsoft Visual Studio 2017 or Microsoft Build Tools for Visual Studio 2017

To configure and install the C BMI bindings from source with cmake,
To configure and install the C BMI bindings from source with CMake,
run the following in a [Developer Command Prompt](https://docs.microsoft.com/en-us/dotnet/framework/tools/developer-command-prompt-for-vs)

mkdir _build && cd _build
Expand All @@ -64,10 +66,10 @@ run the following in a [Developer Command Prompt](https://docs.microsoft.com/en-
-DCMAKE_BUILD_TYPE=Release
cmake --build . --target install --config Release

where `<path-to-installation>` is the base directory
in which to install the bindings (`"C:\Program Files (x86)"` is the default;
note that quotes and an absolute path are needed).

where `<path-to-installation>` is the base directory in which to install the bindings.
The default is `"C:\Program Files (x86)"`.
Note that quotes and an absolute path are needed.
When using a conda environment, use `"%CONDA_PREFIX%\Library"`.

## Use

Expand Down
4 changes: 2 additions & 2 deletions bmic.pc.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: Bmi
Description: The Basic Model Interface
Version: ${BMI_VERSION}
Libs: -L${CMAKE_INSTALL_PREFIX}/lib -lbmic
Cflags: -I${CMAKE_INSTALL_PREFIX}/include
Libs: -L${CMAKE_INSTALL_LIBDIR} -lbmic
Cflags: -I${CMAKE_INSTALL_INCLUDEDIR}

0 comments on commit aabb8e8

Please sign in to comment.