-
-
Notifications
You must be signed in to change notification settings - Fork 107
Including the library in your project
If you are including FastNoise2 in your repo either by direct source copy or git submodule you can do the following
In your CMakeLists.txt
file you will need to include the sub directory where FastNoise2 is. The simplest way is to have a deps/dependencies directory where the source is located `deps/FastNoise2' is what I will assume here.
- Open your
CMakeLists.txt
- Set whatever FastNoise options you would like using `set(FASTNOISE_OPTION ON/OFF CACHE BOOL "Description of option" FORCE)
- Add the sub directory with
add_subdirectory(deps/FastNoise2)
. - Link the FastNoise target to your target using
target_link_libraries(your_project FastNoise)
For an executable it should look something like this
set(FASTNOISE2_NOISETOOL OFF CACHE BOOL "Build Noise Tool" FORCE) #don't need the graph tool
add_subdirectory(deps/FastNoise2)
...
add_executable(your_project ${source})
...
target_link_libraries(your_project PRIVATE FastNoise ...)
If you are adding it to a lib it should be pretty much the same. The only differences are swapping the add_executable
for add_library
and if you are building a static lib you have to make sure the FastNoise target is added as PUBLIC in target_link_libraries
as shown below.
set(FASTNOISE2_NOISETOOL OFF CACHE BOOL "Build Noise Tool" FORCE) #don't need the graph tool
add_subdirectory(deps/FastNoise2)
...
add_library(your_project ${source})
...
target_link_libraries(your_project PUBLIC FastNoise ...)
If you have compiled and installed via CMake or downloaded the binaries from the website you can do the following. You will need to add the library location to the CMAKE_PREFIX_PATH
in your CMakeList.txt
set(CMAKE_PREFIX_PATH lib_directory ${CMAKE_PREFIX_PATH})
...
find_package(FastNoise CONFIG REQUIRED) #use REQUIRED if the lib has to be found for the project to work
...
add_executable(your_project ${source})
...
target_link_libraries(your_project PRIVATE FastNoise ...)
again if you are building FastNoise into a static library (like noted above) use the PUBLIC
attribute rather than PRIVATE
for target_link_libraries
.
Suggest using, https://github.com/caseymcc/UE4CMake
For a manually generated (i.e. not generated by CMake) Visual Studio solution(.sln), you will need to add include/lib directories of the library to your solution.
- Right click on your project and select
Properties
- Select the configuration
Release
,Debug
, etc... You will have to make the changes in steps 3 & 4 for each config. - Select
C\C++
thenGeneral
and modify theAdditional Include Directories
to include the FastNoise2 directory. - Next select
Linker
thenInput
and modify theAdditional Dependencies
to include the FastNoise2 libFastNoise.lib
for release configs andFastNoised.lib
for debug configs.