# CMakeList.txt : CMake project for FastNoise2 cmake_minimum_required(VERSION 3.10) project(FastNoise2 VERSION 1.0.1) set(CMAKE_CXX_STANDARD 17) # determine whether this is a standalone project or included by other projects if (NOT DEFINED FASTNOISE2_STANDALONE_PROJECT) if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) set(FASTNOISE2_STANDALONE_PROJECT ON) else() set(FASTNOISE2_STANDALONE_PROJECT OFF) endif () endif() # Build DLL #set(BUILD_SHARED_LIBS ON) option(FASTNOISE2_TOOLS "Build \"Node Editor\" executable" ${FASTNOISE2_STANDALONE_PROJECT}) option(FASTNOISE2_TESTS "Build tests" OFF) option(FASTNOISE2_UTILITY "Build utility tools" OFF) option(FASTNOISE2_STRICT_FP "Enable strict floating point calculations to ensure output from different SIMD feature sets match EXACTLY" OFF) if(MSVC) #setup pdb target location set(pdb_output_dir "${CMAKE_CURRENT_BINARY_DIR}/pdb-files") set(CMAKE_PDB_OUTPUT_DIRECTORY "${pdb_output_dir}") set(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY "${pdb_output_dir}") #need to sync pdb files add_compile_options("/FS") endif() # Introduce variables: # * CMAKE_INSTALL_LIBDIR # * CMAKE_INSTALL_BINDIR include(GNUInstallDirs) set(install_targets "") # Set default output directories for standalone builds so all # targets (libs and executables) end up in the same location if(FASTNOISE2_STANDALONE_PROJECT) if(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/$/bin) endif() if(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/$/lib) endif() if(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/$/lib) endif() endif() include(cmake/CPM.cmake) add_subdirectory(src) if(FASTNOISE2_TOOLS) add_subdirectory(tools) endif() if(FASTNOISE2_TESTS) add_subdirectory(tests) endif() if(FASTNOISE2_UTILITY) add_subdirectory(util) endif() #Install ----------------------------------------------------------- # Layout. This works for all platforms: # * /lib*/cmake/ # * /lib*/ # * /include/ set(config_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated") # Configuration set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake") set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake") set(targets_export_name "${PROJECT_NAME}Targets") set(namespace "${PROJECT_NAME}::") # Include module with fuction 'write_basic_package_version_file' include(CMakePackageConfigHelpers) # Configure 'ConfigVersion.cmake' # Use: # * PROJECT_VERSION write_basic_package_version_file( "${version_config}" COMPATIBILITY SameMajorVersion ) # Configure 'Config.cmake' # Use variables: # * TARGETS_EXPORT_NAME # * PROJECT_NAME configure_package_config_file( "cmake/Config.cmake.in" "${project_config}" INSTALL_DESTINATION "${config_install_dir}" ) # Targets: # * /lib/libname.a # * header location after install: /include/${PROJECT_NAME}/include.hpp # * headers can be included by C++ code `#include <${PROJECT_NAME}/include.hpp>` install( TARGETS ${install_targets} EXPORT "${targets_export_name}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" ) # Config # * /lib/cmake/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake # * /lib/cmake/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake install( FILES "${project_config}" "${version_config}" DESTINATION "${config_install_dir}" ) # Config # * /lib/cmake/${PROJECT_NAME}/${PROJECT_NAME}Targets.cmake install( EXPORT "${targets_export_name}" NAMESPACE "${namespace}" DESTINATION "${config_install_dir}" ) if(MSVC) #install pdbs get_cmake_property(is_multi GENERATOR_IS_MULTI_CONFIG) if(is_multi) set(config_suffix "$") else() set(config_suffix "") endif() if(BUILD_SHARED_LIBS) set(pdb_dst ${CMAKE_INSTALL_BINDIR}) else() set(pdb_dst ${CMAKE_INSTALL_LIBDIR}) endif() install( DIRECTORY "${pdb_output_dir}/${config_suffix}/" DESTINATION ${pdb_dst} ) endif()