-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0045e97
commit bf25752
Showing
10 changed files
with
222 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 |
---|---|---|
|
@@ -36,3 +36,6 @@ | |
*.exe | ||
*.out | ||
*.app | ||
|
||
# Directories | ||
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,69 @@ | ||
cmake_minimum_required(VERSION 3.24) | ||
project( | ||
forcolormap | ||
LANGUAGES Fortran | ||
VERSION 0.0.0 | ||
) | ||
|
||
# Set a default build type if none was specified | ||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) | ||
message(STATUS "Setting build type to 'Release' as none was specified.") | ||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) | ||
# Set the possible values of build type for cmake-gui | ||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release") | ||
endif() | ||
|
||
# By default, static library | ||
option(BUILD_SHARED_LIBS "Build shared libraries" OFF) | ||
|
||
# Export all symbols on Windows when building libraries | ||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) | ||
|
||
# Utilize the GNU installation structure | ||
include(GNUInstallDirs) | ||
|
||
# Locate the local include directory | ||
set(PROJECT_INCLUDE_DIR ${PROJECT_BINARY_DIR}/include) | ||
|
||
# Dependencies | ||
add_subdirectory(dependencies) | ||
|
||
# Build | ||
add_subdirectory(src) | ||
add_library(${PROJECT_NAME} ${FORCOLORMAP_SOURCES}) | ||
set_target_properties( | ||
${PROJECT_NAME} | ||
PROPERTIES | ||
POSITION_INDEPENDENT_CODE TRUE | ||
OUTPUT_NAME ${PROJECT_NAME} | ||
VERSION ${PROJECT_VERSION} | ||
SOVERSION ${PROJECT_VERSION_MAJOR} | ||
Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_INCLUDEDIR} | ||
) | ||
target_include_directories( | ||
${PROJECT_NAME} | ||
PUBLIC | ||
$<BUILD_INTERFACE:${PROJECT_INCLUDE_DIR}> | ||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> | ||
) | ||
target_link_libraries(${PROJECT_NAME} ${forimage_LIBRARY}) | ||
target_include_directories(${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${forimage_INCLUDE_DIR}>) | ||
|
||
# Installation | ||
add_subdirectory(install) | ||
|
||
# Testing | ||
option(BUILD_TESTING "Build tests") | ||
include(CTest) | ||
message(STATUS "Build FORCOLORMAP tests: ${BUILD_TESTING}") | ||
if (BUILD_TESTING) | ||
enable_testing() | ||
add_subdirectory(test) | ||
endif() | ||
|
||
# Examples | ||
option(BUILD_FORCOLORMAP_EXAMPLES "Build examples") | ||
message(STATUS "Build FORCOLORMAP examples: ${BUILD_FORCOLORMAP_EXAMPLES}") | ||
if (BUILD_FORCOLORMAP_EXAMPLES) | ||
add_subdirectory(example) | ||
endif() |
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 @@ | ||
# Get FORIMAGE | ||
add_subdirectory(forimage) | ||
set(forimage_LIBRARY ${forimage_LIBRARY} PARENT_SCOPE) | ||
set(forimage_INCLUDE_DIR ${forimage_INCLUDE_DIR} PARENT_SCOPE) |
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,29 @@ | ||
# Get the macros and functions we'll need | ||
include(FetchContent) | ||
|
||
# Fetch the proper content | ||
FetchContent_Declare( | ||
forimage | ||
GIT_REPOSITORY "https://github.com/gha3mi/forimage" | ||
GIT_TAG main | ||
) | ||
|
||
FetchContent_MakeAvailable(forimage) | ||
|
||
if (WIN32) | ||
if (BUILD_SHARED_LIBS) | ||
add_custom_command( | ||
TARGET ${PROJECT_NAME} POST_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E copy_if_different | ||
$<TARGET_FILE:forimage> | ||
$<TARGET_FILE_DIR:${PROJECT_NAME} | ||
) | ||
endif() | ||
endif() | ||
|
||
set(forimage_INCLUDE_DIR ${forimage_BINARY_DIR}/include) | ||
set(forimage_INCLUDE_DIR ${forimage_INCLUDE_DIR} PARENT_SCOPE) | ||
|
||
# Make a parent-scope variable for the library | ||
set(forimage_LIBRARY forimage) | ||
set(forimage_LIBRARY ${forimage_LIBRARY} PARENT_SCOPE) |
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,19 @@ | ||
# DEMO_REVERSE | ||
add_executable(demo_reverse demo_reverse.f90) | ||
target_link_libraries(demo_reverse ${PROJECT_NAME}) | ||
|
||
# DEMO | ||
add_executable(demo demo.f90) | ||
target_link_libraries(demo ${PROJECT_NAME}) | ||
|
||
# EXAMPLE1 | ||
add_executable(example1 example1.f90) | ||
target_link_libraries(example1 ${PROJECT_NAME}) | ||
|
||
# EXTRACT | ||
add_executable(extract extract.f90) | ||
target_link_libraries(extract ${PROJECT_NAME}) | ||
|
||
# INFO | ||
add_executable(info info.f90) | ||
target_link_libraries(info ${PROJECT_NAME}) |
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,62 @@ | ||
include(CMakePackageConfigHelpers) | ||
|
||
# Install the library and necessary include files | ||
install( | ||
TARGETS ${PROJECT_NAME} | ||
EXPORT ${PROJECT_NAME}Targets | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
INCLUDES DESTINATION ${CMAKE_INSTALL_PREFIX}/include | ||
) | ||
install( | ||
DIRECTORY ${PROJECT_INCLUDE_DIR} | ||
DESTINATION ${CMAKE_INSTALL_PREFIX} | ||
) | ||
|
||
# Install the C API headers | ||
install( | ||
DIRECTORY ${PROJECT_SOURCE_DIR}/include | ||
DESTINATION ${CMAKE_INSTALL_PREFIX} | ||
) | ||
|
||
# Define the version file | ||
write_basic_package_version_file( | ||
${CMAKE_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake | ||
VERSION ${PROJECT_VERSION} | ||
COMPATIBILITY AnyNewerVersion | ||
) | ||
|
||
export( | ||
EXPORT ${PROJECT_NAME}Targets | ||
FILE ${CMAKE_BINARY_DIR}/${PROJECT_NAME}Targets.cmake | ||
) | ||
|
||
# Define the configuration file | ||
configure_file( | ||
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}Config.cmake.in | ||
${CMAKE_BINARY_DIR}/${PROJECT_NAME}Config.cmake | ||
COPYONLY | ||
) | ||
|
||
install( | ||
EXPORT ${PROJECT_NAME}Targets | ||
FILE ${PROJECT_NAME}Targets.cmake | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} | ||
) | ||
install( | ||
FILES | ||
${CMAKE_BINARY_DIR}/${PROJECT_NAME}Config.cmake | ||
${CMAKE_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} | ||
) | ||
|
||
configure_file( | ||
${CMAKE_CURRENT_SOURCE_DIR}/template.pc | ||
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc | ||
@ONLY | ||
) | ||
install( | ||
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig | ||
) |
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 @@ | ||
if (NOT TARGET forcolormap) | ||
include("${CMAKE_CURRENT_LIST_DIR}/forcolormapTargets.cmake") | ||
endif() |
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,10 @@ | ||
prefix = @CMAKE_INSTALL_PREFIX@ | ||
libdir = ${prefix}/@CMAKE_INSTALL_FULL_LIBDIR@ | ||
includedir = ${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ | ||
|
||
Name: @PROJECT_NAME@ | ||
Description: FORCOLORMAP is a Fortran fpm library for colormaps. | ||
Version: @PROJECT_VERSION@ | ||
URL: https://github.com/vmagnin/forcolormap | ||
Libs: -L${libdir} -l@PROJECT_NAME@ | ||
Cflags: -I${includedir} |
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,11 @@ | ||
set(dir ${CMAKE_CURRENT_SOURCE_DIR}) | ||
|
||
set(FORCOLORMAP_SOURCES | ||
${dir}/colormap_class.f90 | ||
${dir}/colormap_parameters.f90 | ||
${dir}/colormaps_info.f90 | ||
${dir}/matplotlib_colormaps.f90 | ||
${dir}/miscellaneous_colormaps.f90 | ||
${dir}/scientific_colour_maps.f90 | ||
) | ||
set(FORCOLORMAP_SOURCES ${FORCOLORMAP_SOURCES} PARENT_SCOPE) |
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,12 @@ | ||
function(build_test test_name src) | ||
add_executable(${test_name} ${src}) | ||
target_link_libraries(${test_name} PRIVATE ${PROJECT_NAME}) | ||
target_include_directories(${test_name} PUBLIC $<BUILD_INTERFACE:${PROJECT_INCLUDE_DIR}>) | ||
add_test( | ||
NAME ${test_name} | ||
WORKING_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} | ||
COMMAND $<TARGET_FILE:${test_name}> | ||
) | ||
endfunction() | ||
|
||
build_test(check check.f90) |