@@ -10,6 +10,8 @@ endif()
10
10
11
11
project ( SpecUtils VERSION 1.0.0 )
12
12
13
+ enable_testing ()
14
+
13
15
option ( SpecUtils_ENABLE_D3_CHART "Enables exporting of the D3 chart format" ON )
14
16
option ( SpecUtils_D3_SUPPORT_FILE_STATIC "Compiles the JS and CSS files into memory, rather than reading files on disk; disable to allow changing JS/CSS without having to recompile" ON )
15
17
option ( SpecUtils_ENABLE_URI_SPECTRA "Enables encoding/decoding spectra to URIs (for, ex, QR-codes) - requires linking to zlib" OFF )
@@ -21,6 +23,7 @@ option( SpecUtils_BUILD_REGRESSION_TEST "Creates executable to perform interacti
21
23
option ( SpecUtils_BUILD_EXAMPLE "Builds example SpecUtil applications" OFF )
22
24
option ( SpecUtils_PYTHON_BINDINGS "Creates python bindings to the c++ code" OFF )
23
25
option ( SpecUtils_JAVA_SWIG "Creates swig/java bindings to the c++ code" OFF )
26
+ option ( SpecUtils_FORTRAN_SWIG "Creates swig/FORTRAN bindings to the c++ code" OFF )
24
27
option ( SpecUtils_C_BINDINGS "Creates C bindings to the c++ code" OFF )
25
28
option ( SpecUtils_INJA_TEMPLATES "Creates inja template interface" OFF )
26
29
option ( SpecUtils_USE_SIMD "Use SIMD operations; i386/x64 only right now, and very alpha, and extremely minimally used" OFF )
@@ -82,7 +85,7 @@ endif()
82
85
83
86
84
87
# If we are building this on Windows, not as a sub-project, lets enable selecting C++ runtime
85
- if ( MSVC AND ( SpecUtils_PYTHON_BINDINGS OR SpecUtils_BUILD_UNIT_TESTS ) )
88
+ if ( MSVC )
86
89
get_directory_property (hasParent PARENT_DIRECTORY )
87
90
if (NOT hasParent )
88
91
option (${PROJECT_NAME} _USE_MSVC_MultiThreadDLL "Use dynamically-link runtime library." OFF )
@@ -96,7 +99,7 @@ if( MSVC AND (SpecUtils_PYTHON_BINDINGS OR SpecUtils_BUILD_UNIT_TESTS) )
96
99
endif ()
97
100
message (STATUS "Using CMAKE_MSVC_RUNTIME_LIBRARY ${CMAKE_MSVC_RUNTIME_LIBRARY} " )
98
101
endif (NOT hasParent )
99
- endif ( MSVC AND ( SpecUtils_PYTHON_BINDINGS OR SpecUtils_BUILD_UNIT_TESTS ) )
102
+ endif ( MSVC )
100
103
101
104
102
105
if ( SpecUtils_BUILD_EXAMPLE )
@@ -330,7 +333,7 @@ if( SpecUtils_USE_FAST_FLOAT )
330
333
FetchContent_GetProperties ( fast_float )
331
334
FetchContent_MakeAvailable ( fast_float )
332
335
333
- target_include_directories ( SpecUtils PUBLIC ${fast_float_SOURCE_DIR} )
336
+ target_include_directories ( SpecUtils PRIVATE ${fast_float_SOURCE_DIR} )
334
337
endif ( SpecUtils_FETCH_FAST_FLOAT )
335
338
endif ( NOT FAST_FLOAT_FILE_PATH )
336
339
endif ( SpecUtils_USE_FAST_FLOAT )
@@ -417,6 +420,9 @@ if( SpecUtils_JAVA_SWIG )
417
420
target_link_libraries ( SpecUtils PUBLIC ${JAVA_LIBRARIES} )
418
421
endif ( SpecUtils_JAVA_SWIG )
419
422
423
+ if ( SpecUtils_FORTRAN_SWIG )
424
+ add_subdirectory (bindings/swig/fortran )
425
+ endif ( SpecUtils_FORTRAN_SWIG )
420
426
421
427
if ( MINGW )
422
428
target_link_libraries ( SpecUtils PUBLIC -static-libgcc -static libshlwapi.a libpthread.a libstdc++.a libwinpthread.a libmsvcrt.a )
@@ -427,8 +433,8 @@ elseif( WIN32 )
427
433
target_link_libraries ( SpecUtils PUBLIC "Shlwapi.lib" )
428
434
endif ( MINGW )
429
435
430
- target_include_directories ( SpecUtils PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} $ {CMAKE_CURRENT_BINARY_DIR}
431
- PRIVATE ${THIRD_PARTY_DIR} ${Python3_INCLUDE_DIRS } )
436
+ target_include_directories ( SpecUtils PUBLIC $< BUILD_INTERFACE: $ {CMAKE_CURRENT_SOURCE_DIR}> $< BUILD_INTERFACE: $ {CMAKE_CURRENT_BINARY_DIR}>
437
+ PRIVATE ${THIRD_PARTY_DIR} ${PYTHON_INCLUDE_DIRS } )
432
438
433
439
if ( SpecUtils_BUILD_REGRESSION_TEST )
434
440
if ( NOT SpecUtils_ENABLE_EQUALITY_CHECKS )
@@ -450,9 +456,74 @@ if( SpecUtils_BUILD_FUZZING_TESTS )
450
456
add_subdirectory ( fuzz_test )
451
457
endif ( SpecUtils_BUILD_FUZZING_TESTS )
452
458
459
+ set_property ( TARGET SpecUtils PROPERTY POSITION_INDEPENDENT_CODE ON )
460
+
461
+ # Specify installation rules
462
+ include (GNUInstallDirs )
463
+
464
+
465
+ # Install the library
466
+ install (TARGETS SpecUtils
467
+ EXPORT SpecUtilsTargets
468
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
469
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
470
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
471
+ INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
472
+ )
473
+
474
+ set ( SpecUtils_config_OUT ${CMAKE_CURRENT_BINARY_DIR} /SpecUtils_config.h )
453
475
configure_file (
454
476
${CMAKE_CURRENT_SOURCE_DIR} /SpecUtils/SpecUtils_config.h.in
455
- ${CMAKE_CURRENT_BINARY_DIR} /SpecUtils_config.h
477
+ ${SpecUtils_config_OUT}
456
478
)
479
+ LIST (APPEND headers ${SpecUtils_config_OUT} )
480
+ # Install the headers
481
+ install (FILES ${headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} /SpecUtils )
457
482
483
+ # Create and install the CMake package configuration files
484
+ include (CMakePackageConfigHelpers )
485
+
486
+ write_basic_package_version_file (
487
+ "${CMAKE_CURRENT_BINARY_DIR} /SpecUtilsConfigVersion.cmake"
488
+ VERSION ${PROJECT_VERSION}
489
+ COMPATIBILITY AnyNewerVersion
490
+ )
491
+
492
+ configure_package_config_file (
493
+ "${CMAKE_CURRENT_SOURCE_DIR} /SpecUtilsConfig.cmake.in"
494
+ "${CMAKE_CURRENT_BINARY_DIR} /SpecUtilsConfig.cmake"
495
+ INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR} /cmake/SpecUtils
496
+ )
497
+
498
+ install (FILES
499
+ "${CMAKE_CURRENT_BINARY_DIR} /SpecUtilsConfig.cmake"
500
+ "${CMAKE_CURRENT_BINARY_DIR} /SpecUtilsConfigVersion.cmake"
501
+ DESTINATION ${CMAKE_INSTALL_LIBDIR} /cmake/SpecUtils
502
+ )
503
+
504
+ install (EXPORT SpecUtilsTargets
505
+ FILE SpecUtilsTargets.cmake
506
+ NAMESPACE SpecUtils::
507
+ DESTINATION ${CMAKE_INSTALL_LIBDIR} /cmake/SpecUtils
508
+ )
509
+
510
+ set (CPACK_PACKAGE_NAME "SpecUtils" )
511
+
512
+
513
+ if ( SpecUtils_SHARED_LIB )
514
+ set ( SpecUtils_PACKAGE_POSTFIX "SharedLib" )
515
+ else ( SpecUtils_SHARED_LIB )
516
+ set ( SpecUtils_PACKAGE_POSTFIX "StaticLib" )
517
+ endif ( SpecUtils_SHARED_LIB )
518
+
519
+ if ( DEFINED ${PROJECT_NAME} _USE_MSVC_MultiThreadDLL )
520
+ if ( ${PROJECT_NAME} _USE_MSVC_MultiThreadDLL )
521
+ set ( SpecUtils_PACKAGE_POSTFIX "${SpecUtils_PACKAGE_POSTFIX} -SharedRuntime" )
522
+ else ()
523
+ set ( SpecUtils_PACKAGE_POSTFIX "${SpecUtils_PACKAGE_POSTFIX} -StaticRuntime" )
524
+ endif ()
525
+ endif ()
458
526
527
+ set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME} -${CPACK_PACKAGE_VERSION} -${CMAKE_SYSTEM_NAME} -${CMAKE_CXX_COMPILER_ID} -${CMAKE_CXX_COMPILER_VERSION} -${SpecUtils_PACKAGE_POSTFIX} " )
528
+ set (CPACK_GENERATOR "ZIP" )
529
+ include (CPack )
0 commit comments