I've created a static library using CMake and I'm installing the public headers in /usr/local/include/. The library and its tests compile fine on their own, but when using the library in another project I get an error:
/usr/local/include/weftworks/common/network/tcp/acceptor.hpp:28:10: fatal error: utility.hpp: No such file or directory
#include "utility.hpp"
where both acceptor.hpp and utility.hpp are public headers.
This is the related folder structure:
root/
├ cmake/
├ external/
├ library/
│ ├─ include/
│ │ ├─ network/
│ │ │ └─ tcp/
│ │ │ └─ acceptor.hpp
│ │ └─ utility.hpp
│ ├─ src/
│ └─ CMakeLists.txt
├ test/
└ CMakeLists.txt
./library/CMakeLists.txt:
# ./library/CMakeLists.txt
# Required CMake version
cmake_minimum_required(VERSION 3.13)
include(GNUInstallDirs)
# Project details
project(
weftworks-common-library
VERSION 0.4.0
DESCRIPTION "Internal Weftworks Common Library project."
)
# Library target sources
list(APPEND WEFTWORKS_COMMON_LIBRARY_PRIVATE_SOURCES)
list(APPEND WEFTWORKS_COMMON_LIBRARY_PUBLIC_SOURCES)
list(APPEND WEFTWORKS_COMMON_LIBRARY_INTERFACE_SOURCES)
include(src/CMakeLists.txt)
# A static library target
add_library(weftworks-common-library STATIC)
# Required compiler features
target_compile_features(
weftworks-common-library
PUBLIC
cxx_auto_type
cxx_constexpr
cxx_defaulted_functions
cxx_deleted_functions
cxx_final
cxx_lambdas
cxx_noexcept
cxx_override
cxx_range_for
cxx_static_assert
cxx_std_17
cxx_strong_enums
cxx_trailing_return_types
cxx_uniform_initialization
cxx_variadic_macros
)
target_compile_options(
weftworks-common-library
PRIVATE
-Wall
-Wextra
-pedantic
)
target_include_directories(
weftworks-common-library
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>"
)
target_link_libraries(
weftworks-common-library
PUBLIC
Boost::boost
Boost::system
Boost::program_options
spdlog::spdlog
Threads::Threads
)
target_sources(
weftworks-common-library
PUBLIC ${WEFTWORKS_COMMON_LIBRARY_PUBLIC_SOURCES}
INTERFACE ${WEFTWORKS_COMMON_LIBRARY_INTERFACE_SOURCES}
PRIVATE ${WEFTWORKS_COMMON_LIBRARY_PRIVATE_SOURCES}
)
# Create alias target
add_library(weftworks::common-library ALIAS weftworks-common-library)
# Install library target
install(
TARGETS weftworks-common-library
EXPORT weftworks-common-library-config
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(
EXPORT weftworks-common-library-config
NAMESPACE weftworks::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/weftworks/common-library
)
# Install public headers
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/weftworks/common
)
Now I don't know what I need to do to make this work. I'd like to avoid having the "library prefix" in the project structure i.e. library/include/weftworks/common/ to keep it simple.
You need to include "weftworks/common/network/utility.hpp".
This will also ensure that you actually include your header not some other header which someone has written with the very generic name "utility.hpp".
Related
I have a project with structure like this:
project/
├─ src/
│ ├─ main.cpp
│ ├─ CMakeLists.txt
├─ lib/
│ ├─ libapi.so
├─ CMakeLists.txt
├─ dep/
│ ├─ api/
│ │ ├─ api_types.h
In the main CMakeLists I have:
add_subdirectory(dep)
add_executable("my_${PROJECT_NAME}")
add_subdirectory(src)
And in CMakeLists inside src folder:
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
add_library(api SHARED IMPORTED)
set_property(TARGET api PROPERTY IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/lib/libapi.so")
target_sources("my_${PROJECT_NAME}" PRIVATE main.cpp)
In main.cpp I do #include <api_types.h> but I get this error during compile:
api_types.h: No such file or directory
How can I fix it?
First - add_subdirectory in fact just looks for CMakeLists.txt in
the specified directory to apply the sub-set of the rules to the
parent project. If the specified folder doesn't contain any
CMakeLists.txt this command does nothing (i.e. the command
add_subdirectory(dep)).
Second - target_include_directories expects a target object to link against (not the project name). Assuming ${PROJECT_NAME} is not a name of any of your targets (and the code given in the question reveals only two targets my_${PROJECT_NAME} and api) the command target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) does nothing sensible.
Last - you don't specify path to your actual headers anywhere. CMAKE_CURRENT_SOURCE_DIR refers to the current folder CMakeLists.txt is located in. You should specify path to the folder the headers are located in.
Putting all the said info together, the desired content for the top-level CMakeLists.txt should be something like that:
cmake_minimum_required(VERSION 3.20)
set(PROJECT_NAME Hello)
project(${PROJECT_NAME})
add_executable(my_${PROJECT_NAME})
add_subdirectory(src)
And for src's file it's apparently something like that:
target_include_directories(my_${PROJECT_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/dep/api)
target_sources(my_${PROJECT_NAME} PRIVATE main.cpp)
This solution, however, doesn't resolve another mistake in your code - the CMake files you provided don't link the library itself to the executable target. However this is not the question asked, and with respect to the members of the community, I suggest referring to answers to another related question here.
target_include_directories requires your executable as target, in this case my_${PROJECT_NAME}.
You can try
target_include_directories(my_${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
As alternative I would recommend following structure
project/
├─ src/
│ ├─ main.cpp
├─ lib/
│ ├─ libapi.so
├─ CMakeLists.txt
├─ include/
│ ├─ api/
│ │ ├─ api_types.h
with following CMakeList.txt
add_executable(my_${PROJECT_NAME} src/main.cpp)
target_include_directories(my_${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
link_directories(${CMAKE_SOURCE_DIR}/lib)
target_link_libraries(my_${PROJECT_NAME} libapi)
I have a CMake project in C++ and I have been struggling how to setup the CMakeLists.txt files properly. In the external folder there are some dependencies located, which are added to the root CMakelists.txt by the add_subdirectory command. It is important to mention that Project_B needs Project_A. Here is the simplified version of the folder structure:
$ tree
.
├── external
│ ├── Project_A
| ├──include
| ├── project_A.h
│ ├── projectA_0.cpp
│ └── CMakeLists.txt
|
| ├── Project_B
| ├──include
| ├── project_B.h
│ ├── projectB_0.cpp
│ └── CMakeLists.txt
|
├── root_0.cpp
├── root_1.cpp
└── CMakeLists.txt
Here is the simplified root CMakeLists.txt
# root CMakeLists.txt
cmake_minimum_required(VERSION 3.19)
project(foo)
add_subdirectory(external/Project_A)
add_subdirectory(external/Project_B)
add_executable(${PROJECT_NAME} root_0.cpp
root_1.cpp)
target_include_directories(${PROJECT_NAME} PUBLIC
external/Project_A/include
external/Project_B/include)
target_link_libraries(${PROJECT_NAME} PUBLIC
project_a
project_b)
Here is the CMakeLists.txt of Project_A, which is also a dependency for Project_B. I decided to create a config.cmake file for this project and import it by Project_B.
# Project_A CMakeLists.txt
cmake_minimum_required(VERSION 3.19)
project(project_a)
target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
add_library(${PROJECT_NAME} STATIC projectA_0.cpp)
export(TARGETS ${PROJECT_NAME}
NAMESPACE project_a::
FILE ${CMAKE_SOURCE_DIR}/project_a_Config.cmake )
and here is the CMakeLists.txt of Project_B.The project_a_Config.cmake is loaded with the help of find_package() function. The path of the include dir from A is written in the project_a_Config.cmake. However, I can not make those headers included properly. Should I use a *.cmake.in file?
# Project_B CMakeLists.txt
cmake_minimum_required(VERSION 3.19)
project(project_b)
add_library(${PROJECT_NAME} STATIC projectB_0.cpp)
find_package(project_a CONFIG REQUIRED HINTS ../)
target_include_directories(${PROJECT_NAME} PUBLIC
include
project_a::project_a )
target_link_libraries(${PROJECT_NAME} PUBLIC
project_a )
If there are any further problems with the structure or the used functions, just let me know! Thank you!
I'm trying to build Zlib and quazip automatic with the rest of my project. I want to do it in a similar way as I add googletest to my project.
zLib and Quazip shall be linked static to my App.
I want to to this because of CI/ CD reasons and if somebody else wants to build the project he do not have to worry about those dependencies (especially under windows)...
Download it at configure time with CMake ExternalProject_Add
add it on target level
My structure is like the following:
project/
├── CMakelists.txt (1)
├── sources/
│ ├── APP/
│ │ ├── CMakeLists.txt (2)
│ │ ├── thirdparty/
│ │ │ ├── CMakeLists.txt (3)
│ │ │ ├── zlib
│ │ │ │ ├── CMakeLists.txt.in
│ │ │ ├── quazip
│ │ │ │ ├── CMakeLists.txt.in
│ │ │ │ ├── CMakeListsBuild.txt.in
Thats complicated enough but let me show you what I do where...
(1) CMakeLists.txt
Noting special just adding all the packages together like APP
(2) CMakeLists.txt
cmake_minimum_required(VERSION 3.15.2)
project(Project VERSION 0.0.1)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
#Add the needed Qt Components
find_package(Qt5 COMPONENTS
Core
Network
REQUIRED)
add_subdirectory(thirdparty)
SET(INCLUDES
...
)
SET(SOURCES
...
)
target_compile_options(${PROJECT_NAME} PUBLIC
...
)
target_compile_definitions(${PROJECT_NAME} PUBLIC
QUAZIP_STATIC )
target_include_directories(${PROJECT_NAME} PRIVATE
OtherIncludes
"${QUAZIP_INCLUDE_DIR}"
)
target_link_libraries(${PROJECT_NAME}
Qt5::Network
Qt5::Core
SomeOtherDep
quazip_static <---- adding static targets here
zlibstatic <---- adding static targets here
)
(3) CMakeLists.txt
# Download and unpack at configure time
configure_file(zlib/CMakeLists.txt.in zlib-download/CMakeLists.txt)
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/zlib-download"
)
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/zlib-download"
)
add_subdirectory("${CMAKE_BINARY_DIR}/zlib-src"
"${CMAKE_BINARY_DIR}/zlib-build"
)
# Download and unpack at configure time
configure_file(quazip/CMakeLists.txt.in quazip-download/CMakeLists.txt)
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/quazip-download"
)
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/quazip-download"
)
configure_file(quazip/CMakeListsBuild.txt.in ${CMAKE_BINARY_DIR}/quazip-src/CMakeLists.txt COPYONLY)
add_subdirectory("${CMAKE_BINARY_DIR}/quazip-src"
"${CMAKE_BINARY_DIR}/quazip-build"
)
set(QUAZIP_INCLUDE_DIR
"${CMAKE_BINARY_DIR}/quazip-src/quazip" PARENT_SCOPE)
The two CMakeLists.txt.in have nearly the same Content...
cmake_minimum_required(VERSION 2.8.2)
include(ExternalProject)
project(quazip-download NONE)
ExternalProject_Add(quazip
GIT_REPOSITORY git://github.com/stachenov/quazip.git
GIT_TAG v0.8.1
SOURCE_DIR "${CMAKE_BINARY_DIR}/quazip-src"
BINARY_DIR "${CMAKE_BINARY_DIR}/quazip-build"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)
cmake_minimum_required(VERSION 2.8.2)
include(ExternalProject)
project(zlib-download NONE)
ExternalProject_Add(zlib
GIT_REPOSITORY git://github.com/madler/zlib.git
GIT_TAG v1.2.11
SOURCE_DIR "${CMAKE_BINARY_DIR}/zlib-src"
BINARY_DIR "${CMAKE_BINARY_DIR}/zlib-build"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)
Then there is the last CMakeListsBuild.txt.in in the quazip folder. I'm just editing the original one and feed the zlib dependencies directly in. It looks like this:
cmake_minimum_required(VERSION 2.6)
project(QuaZip)
...
EVERYTHING ORIGINAL
...
# Use system zlib on unix and Qt ZLIB on Windows
# will be set from outside ZLIB_LIBRARIES ZLIB_INCLUDE_DIRS
--------------------ADDED BY ME REMOVED find_packages...
set(ZLIB_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/zlib-src
${CMAKE_BINARY_DIR}/zlib-build)
if(UNIX)
set(ZLIB_LIBRARIES
"${CMAKE_BINARY_DIR}/zlib-build/libz.a")
elseif(MINGW)
set(ZLIB_LIBRARIES
"${CMAKE_BINARY_DIR}/zlib-build/libzlibstatic.a")
endif()
...
EVERYTHING ORIGINAL
...
Question
Downloading and building the static lib of zlib works but I get the following error while compiling under linux.
/home/linuxmint/someDirectory/build/zlib-src/test/example.c:8:10: fatal error: zlib.h: No such file or directory
#include "zlib.h"
^~~~~~~~
compilation terminated.
zlib-build/CMakeFiles/example.dir/build.make:75: recipe for target 'zlib-build/CMakeFiles/example.dir/test/example.o' failed
make[2]: *** [zlib-build/CMakeFiles/example.dir/test/example.o] Error 1
CMakeFiles/Makefile2:1355: recipe for target 'zlib-build/CMakeFiles/example.dir/all' failed
make[1]: *** [zlib-build/CMakeFiles/example.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
This is the strange part I dont understand. If I have a look in the CMakeLists of zlib. (LINK)
They add everything of of the source and binary folder to the include with this:
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
So I don't understand why the example of zlib (and everything else which need zlib.h) can't be build...
Perhabs somebody has a hint...
Thanks...
Edit
If I install the headers with apt building works... But why ;) Since nowhere find_package is called...
Thanks to #squarekittles who pointed me in the right direction.
In the CMakeLists.txt of zlib the include dir is specified as ${CMAKE_SOURCE_DIR}. This is of course the wrong directory...
I added a additional CMakeLists.txt.in for zlib which will replace the original one. It's all the same only two lines are different:
...
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
^~~~~~~~~~~~~ Added in
#============================================================================
# zlib
#============================================================================
set(ZLIB_PUBLIC_HDRS
${CMAKE_CURRENT_BINARY_DIR}/zconf.h
${CMAKE_CURRENT_SOURCE_DIR}/zlib.h
) ^~~~~~~~~~~~~ Added in
...
Now the examples compile...
Also I needed to add the headers of zlib to my project did it by editing CMakeLists.txt (3)
...
configure_file(zlib/CMakeListsBuild.txt.in ${CMAKE_BINARY_DIR}/zlib-src/CMakeLists.txt COPYONLY) <--- Replacing CMakeLists.txt for zlib
...
set(QUAZIP_INCLUDE_DIR
"${CMAKE_BINARY_DIR}/quazip-src/quazip"
${ZLIB_INCLUDE_DIR} PARENT_SCOPE)
^~~~~~~~~~~~ Added in
...
I would like to compile a project so I would be able to use it as a library in other projects.
To be more precise it is a base class that I would like many other project I use to inherit from.
├── include
│ ├── MyBase.hpp
│ ├── ...
│ └── Utils.hpp
└── src
├── MyBase.cpp
├── ...
└── Utils.cpp
After I followed a tutorial and adjusted My CMakeLists.txt file and now it looks like this.
cmake_minimum_required(VERSION 2.8.3)
project(my_commons)
set(CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS}")
find_package(catkin REQUIRED COMPONENTS
roscpp
tf
)
catkin_package(CATKIN_DEPENDS tf
INCLUDE_DIRS include)
include_directories(
${catkin_INCLUDE_DIRS}
include/
)
###########
## Build ##
###########
add_library(my_commons SHARED
src/MyBase.cpp
src/Utils.cpp
)
## Specify libraries to link a library or executable target against
set_target_properties(my_commons PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(my_commons
${catkin_LIBRARIES}
${roscpp_LIBRARIES}
)
install(DIRECTORY include/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.hpp"
PATTERN ".svn" EXCLUDE)
# Install library
install(TARGETS my_commons
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
It compiles fine, but I am not sure what needs to be added in other projects' CMakeFiles and how to use it there.
Thank you very much in advance.
In the CMakeLists.txt file you included above, you need to add a libraries line in the catkin_package as follows:
catkin_package(
INCLUDE_DIRS include
LIBRARIES ${PROJECT_NAME}
CATKIN_DEPENDS tf
)
Then in other nodes, you would include the package in packages.xml:
<build_depend>my_commons</build_depend>
And in the CMakeLists.txt file you would need to find the my_commons package and link it against a library or executable you are trying to build by doing the following:
find_package(catkin REQUIRED COMPONENTS
roscpp
my_commons
)
catkin_package(
INCLUDE_DIRS include
LIBRARIES ${PROJECT_NAME}
CATKIN_DEPENDS my_commons
)
target_link_libraries(${PROJECT_NAME}
${my_commons_LIBRARIES}
)
I have an imported library that I am trying to link using CMake. However, the library always shows up empty (or not found). I know that imported libraries have different visibility rules (according to this thread) than the standard libraries, but no matter what I try the library always ends up missing. To start, here's my folder structure:
Root
├── build
├── cmake
├── src
│ ├── external
│ │ ├── openvdb
│ │ │ ├── openvdb
│ │ │ ├── cmake
│ │ │ ├── CMakeLists.txt
│ │ ├── tbb
│ │ ├── zlib
│ │ ├── CMakeLists.txt
│ ├── CMakeLists.txt
├── CMakeLists.txt
In my Root CMakeLists.txt file I add the libraries called TBB_LIBS and TBBMALLOC_LIBS like this:
cmake_minimum_required(VERSION 3.2.2 FATAL_ERROR)
include(ExternalProject)
project(openVDBBuild)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (WIN32)
set(CMAKE_CXX_FLAGS "-bigobj /EHsc")
endif ()
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
if(NOT CMAKE_DEBUG_POSTFIX)
set(CMAKE_DEBUG_POSTFIX debug)
endif()
if(NOT CMAKE_RELEASE_POSTFIX)
set(CMAKE_RELEASE_POSTFIX release)
endif()
set(BUILD_VARIANTS "release debug")
set(TBB_PREFIX "tbb")
set(TBB_LIBS_DIR "${CMAKE_SOURCE_DIR}/src/external/tbb/build/${TBB_PREFIX}_")
set(TBB_ROOT ${CMAKE_SOURCE_DIR}/src/external/tbb)
set(TBB_INCLUDE_DIR ${TBB_ROOT}/include)
#********** Here I create the library and add the Global Flag ***********
add_library(TBBMALLOC_LIBS SHARED IMPORTED GLOBAL)
add_library(TBB_LIBS SHARED IMPORTED GLOBAL)
if (WIN32)
#********** Here I set different paths for debug and release versions of the library ***********
set_property(TARGET TBBMALLOC_LIBS PROPERTY IMPORTED_LOCATION_RELEASE ${CMAKE_BINARY_DIR}/lib/tbbmalloc.dll )
set_property(TARGET TBBMALLOC_LIBS PROPERTY IMPORTED_LOCATION_DEBUG ${CMAKE_BINARY_DIR}/lib/tbbmalloc_${CMAKE_DEBUG_POSTFIX}.dll )
set_property(TARGET TBB_LIBS PROPERTY IMPORTED_LOCATION_RELEASE ${CMAKE_BINARY_DIR}/lib/tbb.dll )
set_property(TARGET TBB_LIBS PROPERTY IMPORTED_LOCATION_DEBUG ${CMAKE_BINARY_DIR}/lib/tbb_${CMAKE_DEBUG_POSTFIX}.dll )
add_custom_command(
TARGET ProjectTbbExternal
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "$<$<CONFIG:debug>:${TBB_LIBS_DIR}${CMAKE_DEBUG_POSTFIX}/tbb_${CMAKE_DEBUG_POSTFIX}.dll>$<$<CONFIG:release>:${TBB_LIBS_DIR}${CMAKE_RELEASE_POSTFIX}/tbb.dll>" "${CMAKE_BINARY_DIR}/lib"
COMMAND ${CMAKE_COMMAND} -E copy "$<$<CONFIG:debug>:${TBB_LIBS_DIR}${CMAKE_DEBUG_POSTFIX}/tbbmalloc_${CMAKE_DEBUG_POSTFIX}.dll>$<$<CONFIG:release>:${TBB_LIBS_DIR}${CMAKE_RELEASE_POSTFIX}/tbbmalloc.dll>" "${CMAKE_BINARY_DIR}/lib"
COMMAND ${CMAKE_COMMAND} -E copy "$<$<CONFIG:debug>:${TBB_LIBS_DIR}${CMAKE_DEBUG_POSTFIX}/tbbmalloc_proxy_${CMAKE_DEBUG_POSTFIX}.dll>$<$<CONFIG:release>:${TBB_LIBS_DIR}${CMAKE_RELEASE_POSTFIX}/tbbmalloc_proxy.dll>" "${CMAKE_BINARY_DIR}/lib"
)
endif ()
add_subdirectory("src")
Now, down inside the CMakeLists.txt in the src/external/openvdb directory I try to link the libraries like this:
project(OpenVDBCore)
#define OPENVDB_LIBRARY_MAJOR_VERSION_NUMBER 4
#define OPENVDB_LIBRARY_MINOR_VERSION_NUMBER 0
#define OPENVDB_LIBRARY_PATCH_VERSION_NUMBER 0
#*********** I'm going to omit some lines here since **********
#*********** they're standard for the OpenVDB build ***********
SET_SOURCE_FILES_PROPERTIES ( ${OPENVDB_LIBRARY_SOURCE_FILES}
PROPERTIES
COMPILE_FLAGS "-DOPENVDB_PRIVATE -DOPENVDB_USE_BLOSC ${OPENVDB_USE_GLFW_FLAG}"
)
ADD_LIBRARY ( openvdb_static STATIC ${OPENVDB_LIBRARY_SOURCE_FILES} )
ADD_LIBRARY ( openvdb_shared SHARED ${OPENVDB_LIBRARY_SOURCE_FILES} )
TARGET_LINK_LIBRARIES ( openvdb_static
zlib
TBB_LIBS
TBBMALLOC_LIBS
)
TARGET_LINK_LIBRARIES ( openvdb_shared
zlib
TBB_LIBS
TBBMALLOC_LIBS
)
MESSAGE(STATUS "TBB_LIBS library location is ${TBB_LIBS}")
MESSAGE(STATUS "TBBMALLOC_LIBS library location is ${TBBMALLOC_LIBS}")
You can see that I put a status message in CMake to see what the ${TBB_LIBS} and ${TBBMALLOC_LIBS} variables are... but that part is always empty. Accordingly, the openvdb_shared and openvdb_static project files that get generated by CMake also do not link the libraries correctly (since those libraries are unknown). Does anyone know why this occurs (and how to fix it)?