[libnoise] Fix build and header, install FindLibNoise.cmake (#14141)

This commit is contained in:
Jack·Boos·Yu 2020-10-21 16:31:06 -07:00 committed by GitHub
parent 291df75125
commit 51fce8c8d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 72 additions and 8 deletions

View File

@ -1,3 +1,5 @@
Source: libnoise
Version: 1.0.0
Port-Version: 1
Homepage: https://github.com/RobertHue/libnoise
Description: A general-purpose library that generates three-dimensional coherent noise. Useful for terrain generation and procedural texture generation. Uses a broad number of techniques (Perlin noise, ridged multifractal, etc.) and combinations of those techniques.

View File

@ -0,0 +1,56 @@
diff --git a/noiseutils/CMakeLists.txt b/noiseutils/CMakeLists.txt
index 07747de..08c0bda 100644
--- a/noiseutils/CMakeLists.txt
+++ b/noiseutils/CMakeLists.txt
@@ -22,8 +22,11 @@ if(BUILD_SHARED_LIBS)
target_include_directories(${TARGET_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/src)
# install dynamic libraries (.dll or .so) into /bin
- install(TARGETS ${TARGET_NAME} DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
-endif()
+ install(TARGETS ${TARGET_NAME}
+ RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin"
+ LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/lib"
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
+else()
#----------------------------------------
# build static lib (it's good practice to include a lib file for the dll)
@@ -35,7 +38,7 @@ target_include_directories(${TARGET_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/src)
# install static libraries (.lib) into /lib
install(TARGETS ${TARGET_NAME} DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
#----------------------------------------
-
+endif()
# install include files into /include
install( FILES "${PROJECT_SOURCE_DIR}/noiseutils/noiseutils.h"
DESTINATION "${CMAKE_INSTALL_PREFIX}/include/noise" )
\ No newline at end of file
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2757f30..7a135c2 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -62,8 +62,11 @@ if(BUILD_SHARED_LIBS)
set_target_properties(${TARGET_NAME} PROPERTIES VERSION ${LIBNOISE_VERSION})
target_include_directories(${TARGET_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/src)
target_compile_definitions(${TARGET_NAME} PRIVATE NOISE_BUILD_DLL)
- install(TARGETS ${TARGET_NAME} DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
-endif()
+ install(TARGETS ${TARGET_NAME}
+ RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin"
+ LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/lib"
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
+else()
#----------------------------------------
# build static lib (it's good practice to include a lib file for the dll)
@@ -76,7 +79,7 @@ target_compile_definitions(${TARGET_NAME} PUBLIC NOISE_STATIC)
# install static libraries (.lib) into /lib
install(TARGETS ${TARGET_NAME} DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
#----------------------------------------
-
+endif()
# install include files into /include
install( DIRECTORY "${PROJECT_SOURCE_DIR}/src/noise"
DESTINATION "${CMAKE_INSTALL_PREFIX}/include" )
\ No newline at end of file

View File

@ -1,5 +1,3 @@
include(vcpkg_common_functions)
set( LIBNOISE_VERSION "1.0.0" )
set( LIBNOISE_COMMIT "d7e68784a2b24c632868506780eba336ede74ecd" )
@ -9,21 +7,29 @@ vcpkg_from_github(
REF ${LIBNOISE_COMMIT}
SHA512 8c4d654acb4ae3d90ee62ebdf0447f876022dcb887ebfad88f39b09d29183a58e6fc1b1f1d03edff804975c8befcc6eda33c44797495285aae338c2e869a14d7
HEAD_REF master
PATCHES fix-build.patch
)
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
-DBUILD_WALL=ON
-DBUILD_SPEED_OPTIMIZED=ON
-DBUILD_LIBNOISE_DOCUMENTATION=OFF
-DBUILD_LIBNOISE_UTILS=ON
-DBUILD_LIBNOISE_EXAMPLES=OFF
)
vcpkg_install_cmake()
# Include files should not be duplicated into the /debug/include directory.
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
# Handle copyright
file(COPY ${SOURCE_PATH}/LICENSE.md DESTINATION ${CURRENT_PACKAGES_DIR}/share/libnoise)
file(RENAME ${CURRENT_PACKAGES_DIR}/share/libnoise/LICENSE.md ${CURRENT_PACKAGES_DIR}/share/libnoise/copyright)
if (VCPKG_LIBRARY_LINKAGE STREQUAL static)
vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/include/noise/module/modulebase.h
"if NOISE_STATIC" "if 1" )
endif()
# Post-build test for cmake libraries
vcpkg_test_cmake(PACKAGE_NAME libnoise)
file(INSTALL ${SOURCE_PATH}/cmake/Modules/FindLibNoise.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT})
file(INSTALL ${SOURCE_PATH}/LICENSE.md DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)