Skip to content
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

Pr cmake #8

Open
wants to merge 18 commits into
base: master
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
64 changes: 64 additions & 0 deletions .github/workflows/compile-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Compile and test Release & Debug builds
# using https://levelup.gitconnected.com/utilizing-github-actions-to-build-and-test-on-multiple-platforms-a7fe3aa6ce2a

on:
push:
branches: [ PR_cmake ]

pull_request:
branches: [ PR_cmake ]

workflow_dispatch:

defaults:
run:
shell: bash

jobs:
build_and_test:
name: >
Build and test a ${{ matrix.build }} version of ITM on
${{ matrix.os }} with ${{ matrix.compiler }}.
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
compiler: [ g++-10 ]
build: [Release]
include:
- os: ubuntu-latest
target: Linux
# - os: macos-latest
# target: Macos
- os: windows-latest
compiler: cl
target: Windows
build: Release
# # - os: windows-latest
# compiler: cl
# target: Windows
# build: Debug

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Linux/MacOS compile
if: ${{ matrix.os != 'windows-latest' }}
uses: lukka/run-cmake@v3
with:
cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
buildDirectory: "${{ github.workspace }}/build"
buildWithCMake: true

- name: Add msbuild to PATH
if: ${{ matrix.os == 'windows-latest' }}
uses: microsoft/[email protected]

- name: Compile for Windows
if: ${{ matrix.os == 'windows-latest' }}
uses: lukka/run-cmake@v3
with:
cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
buildDirectory: "${{ github.workspace }}/build"
buildWithCMake: true
78 changes: 78 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#
# Cmake for a shared library using directions at https://stackoverflow.com/questions/17511496/how-to-create-a-shared-library-with-cmake
#
cmake_minimum_required(VERSION 3.16)

project(itmlib VERSION 1.3 DESCRIPTION "NTIA Irregular Terrain Model library")

SET(itmlib_SRC
src/ComputeDeltaH.cpp
src/DiffractionLoss.cpp
src/FindHorizons.cpp
src/FreeSpaceLoss.cpp
src/FresnelIntegral.cpp
src/H0Function.cpp
src/InitializeArea.cpp
src/InitializePointToPoint.cpp
src/InverseComplementaryCumulativeDistributionFunction.cpp
src/itm_area.cpp
src/itm_p2p.cpp
src/KnifeEdgeDiffraction.cpp
src/LinearLeastSquaresFit.cpp
src/LineOfSightLoss.cpp
src/LongleyRice.cpp
src/QuickPfl.cpp
src/SigmaHFunction.cpp
src/SmoothEarthDiffraction.cpp
src/TerrainRoughness.cpp
src/TroposcatterLoss.cpp
src/ValidateInputs.cpp
src/Variability.cpp
)

set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS YES CACHE BOOL "Export all symbols")

#
# run cmake -DBUILD_SHARED_LIBS=ON if you want shared libs
# See https://cgold.readthedocs.io/en/latest/tutorials/libraries/static-shared.html
#
add_library(itmlib ${itmlib_SRC})

set_target_properties(itmlib PROPERTIES VERSION ${PROJECT_VERSION})
set_target_properties(itmlib PROPERTIES SOVERSION 0)
add_compile_definitions(
ITMLIB_VERSION="${PROJECT_VERSION}.0")

# Use C++14 -- needed because of initializers
set_property(TARGET itmlib PROPERTY CXX_STANDARD 14)

set_target_properties(itmlib PROPERTIES PUBLIC_HEADER include/itm.h)
set_target_properties(itmlib PROPERTIES PUBLIC_HEADER include/Enums.h)
set_target_properties(itmlib PROPERTIES PUBLIC_HEADER include/Errors.h)
set_target_properties(itmlib PROPERTIES PUBLIC_HEADER include/Warnigns.h)

# Only Cmake 3.20+ provides platform independent way to construct paths
IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER_EQUAL 3.20)
cmake_path(APPEND itminclude "${CMAKE_SOURCE_DIR}" "include")
ELSE (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER_EQUAL 3.20)
set(itminclude "${CMAKE_SOURCE_DIR}/include")
ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER_EQUAL 3.20)

#
# inclue the include directory
#
target_include_directories(itmlib PRIVATE ${itminclude})

include(GNUInstallDirs)
install(TARGETS itmlib
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/itmlib
)

# pkg_check_modules()

configure_file(itmlib.pc.in itmlib.pc @ONLY)

install(FILES ${CMAKE_BINARY_DIR}/itmlib.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)

add_subdirectory(win32/ITMDrvr)
6 changes: 5 additions & 1 deletion include/itm.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
using namespace std;

// Export the DLL functions as "C" and not C++
#define DLLEXPORT extern "C" __declspec(dllexport)
#ifdef _WIN32
# define DLLEXPORT extern "C" __declspec(dllexport)
#else
# define DLLEXPORT extern "C"
#endif
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#define DIM(x, y) (((x) > (y)) ? (x - y) : (0))
Expand Down
12 changes: 12 additions & 0 deletions itmlib.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=@CMAKE_INSTALL_PREFIX@
libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@

Name: @PROJECT_NAME@
Description: @PROJECT_DESCRIPTION@
Version: @PROJECT_VERSION@

Requires:
Libs: -L${libdir} -litmlib
Cflags: -I${includedir}
2 changes: 1 addition & 1 deletion src/ComputeDeltaH.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "..\include\itm.h"
#include "itm.h"

/*=============================================================================
|
Expand Down
2 changes: 1 addition & 1 deletion src/DiffractionLoss.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "..\include\itm.h"
#include "itm.h"

/*=============================================================================
|
Expand Down
2 changes: 1 addition & 1 deletion src/FindHorizons.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "..\include\itm.h"
#include "itm.h"

/*=============================================================================
|
Expand Down
2 changes: 1 addition & 1 deletion src/FreeSpaceLoss.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "..\include\itm.h"
#include "itm.h"

/*=============================================================================
|
Expand Down
2 changes: 1 addition & 1 deletion src/FresnelIntegral.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "..\include\itm.h"
#include "itm.h"

/*=============================================================================
|
Expand Down
2 changes: 1 addition & 1 deletion src/H0Function.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "..\include\itm.h"
#include "itm.h"

/*=============================================================================
|
Expand Down
4 changes: 2 additions & 2 deletions src/InitializeArea.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "..\include\itm.h"
#include "..\include\Enums.h"
#include "itm.h"
#include "Enums.h"

/*=============================================================================
|
Expand Down
4 changes: 2 additions & 2 deletions src/InitializePointToPoint.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "..\include\itm.h"
#include "..\include\Enums.h"
#include "itm.h"
#include "Enums.h"

/*=============================================================================
|
Expand Down
2 changes: 1 addition & 1 deletion src/InverseComplementaryCumulativeDistributionFunction.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "..\include\itm.h"
#include "itm.h"

/*=============================================================================
|
Expand Down
2 changes: 1 addition & 1 deletion src/KnifeEdgeDiffraction.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "..\include\itm.h"
#include "itm.h"

/*=============================================================================
|
Expand Down
2 changes: 1 addition & 1 deletion src/LineOfSightLoss.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "..\include\itm.h"
#include "itm.h"

/*=============================================================================
|
Expand Down
2 changes: 1 addition & 1 deletion src/LinearLeastSquaresFit.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "..\include\itm.h"
#include "itm.h"

/*=============================================================================
|
Expand Down
8 changes: 4 additions & 4 deletions src/LongleyRice.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "..\include\itm.h"
#include "..\include\Enums.h"
#include "..\include\Errors.h"
#include "..\include\Warnings.h"
#include "itm.h"
#include "Enums.h"
#include "Errors.h"
#include "Warnings.h"

/*=============================================================================
|
Expand Down
2 changes: 1 addition & 1 deletion src/QuickPfl.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "..\include\itm.h"
#include "itm.h"

/*=============================================================================
|
Expand Down
2 changes: 1 addition & 1 deletion src/SigmaHFunction.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "..\include\itm.h"
#include "itm.h"

/*=============================================================================
|
Expand Down
2 changes: 1 addition & 1 deletion src/SmoothEarthDiffraction.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "..\include\itm.h"
#include "itm.h"

/*=============================================================================
|
Expand Down
2 changes: 1 addition & 1 deletion src/TerrainRoughness.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "..\include\itm.h"
#include "itm.h"

/*=============================================================================
|
Expand Down
2 changes: 1 addition & 1 deletion src/TroposcatterLoss.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "..\include\itm.h"
#include "itm.h"

/*=============================================================================
|
Expand Down
8 changes: 4 additions & 4 deletions src/ValidateInputs.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "..\include\itm.h"
#include "..\include\Enums.h"
#include "..\include\Errors.h"
#include "..\include\Warnings.h"
#include "itm.h"
#include "Enums.h"
#include "Errors.h"
#include "Warnings.h"

/*=============================================================================
|
Expand Down
6 changes: 3 additions & 3 deletions src/Variability.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "..\include\itm.h"
#include "..\include\Enums.h"
#include "..\include\Warnings.h"
#include "itm.h"
#include "Enums.h"
#include "Warnings.h"

/*=============================================================================
|
Expand Down
6 changes: 3 additions & 3 deletions src/itm_area.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "..\include\itm.h"
#include "..\include\Enums.h"
#include "..\include\Errors.h"
#include "itm.h"
#include "Enums.h"
#include "Errors.h"

/*=============================================================================
|
Expand Down
6 changes: 3 additions & 3 deletions src/itm_p2p.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "..\include\itm.h"
#include "..\include\Enums.h"
#include "..\include\Errors.h"
#include "itm.h"
#include "Enums.h"
#include "Errors.h"

/*=============================================================================
|
Expand Down
Loading