-
Notifications
You must be signed in to change notification settings - Fork 186
Developing TileDB in CLion
CLion is an IDE for C++ development that has good support for CMake-based project. However, it does not handle very well the CMake structure used by TileDB, referred to as a "superbuild" (see this issue).
In the superbuild, all of the dependencies of TileDB are managed using CMake external projects. This allows us to automatically and portably install TileDB dependencies without relying on external package managers, or requiring superuser privileges.
During the initial configuration phase, when you first invoke cmake
, we check for the dependencies in standard system locations. If a dependency is not found, it is added as an external project (EP). We also add TileDB itself as an EP, to allow us to express a dependency graph across EPs (the TileDB EP depends on the dependency EPs). Next, when you start the build by invoking make
or cmake --build .
, any EPs that were added are first downloaded, configured, built and installed in the TileDB build directory.
The TileDB EP is processed last. The TileDB EP simply invokes cmake
inside the tiledb
build directory, as there is no download step. This configures and starts the build for TileDB itself, now that the dependencies have been installed in a known location.
CLion does not know about the build targets within the TileDB external project. Therefore, when you first set up the TileDB project in CLion, you should follow these steps:
- Run the default
Build All
target once in the Debug profile. This will invoke the superbuild and build the dependencies. If you don't have aBuild All
target you can create one viaEdit Configurations -> Application -> Add new configuration
. - Edit the CMake "Profile" in CLion for the profile you just built (Debug) and add the CMake build option
-DTILEDB_CMAKE_IDE=ON
. This will disable the superbuild for the Debug configuration, which will cause the normal TileDB build targets to be available to CLion. - Repeat this process as required for the other profiles (like Release).
CLion has special support for tests using the Catch framework. Follow these steps:
- Edit your run configurations (Run menu -> Edit configurations).
- Add a new "Catch" configuration by clicking the "+" button.
- Choose the
tiledb_unit
target for the Catch configuration.
If -DTILEDB_HDFS=ON
- (macOS Only) If building / testing against HDFS, enable JVM signal chaining for Catch:
- Add environment variable:
DYLD_FORCE_FLAT_NAMESPACE=1
Note: Catch should automatically properly link to the libjsig library during the build process
Now you should be able to run and debug the unit tests within CLion.
If the build configuration you're developing requires a specific build option (e.g. TILEDB_S3
or TILEDB_SERIALIZATION
) you may run into the issue that CLion does not pick up the corresponding preprocessor definitions. This means that portions of code with #ifdef TILEDB_SERIALIZATION
will be marked as unreachable by CLion, even if you set the option -DTILEDB_SERIALIZATION=ON
during configuration time. Code highlighting, syntax checking, etc. will be disabled in these regions.
Method 1
The method to fix this is to manually define the corresponding definition on the toplevel CMakeLists.txt
file. E.g. for serialization, edit TileDB/CMakeLists.txt
and below the section with all of the option(...)
lines, add the explicit definition:
# Don't commit this!
set(TILEDB_SERIALIZATION ON)
add_definitions(-DTILEDB_SERIALIZATION)
Then reload the project in CLion with Tools -> CMake -> Reset Cache and Reload Project
.
Method 2
A second method can be used in case that the build configuration you're developing requires a specific build option (e.g. TILEDB_S3
or TILEDB_SERIALIZATION
). It will require though some manual steps, but it will save you from modifying toplevel CMakeLists.txt
file.
- Create a directory for your build.
mkdir build
- Jump into the directory you just created
cd build
- Run the bootstrap script to create a superbuild of the project
../bootstrap .. && make -j4
. This will install all the external packages - Create a debug profile
File -> Settings -> Build, Execution, Deployment -> Cmake
and point theBuild directory
to yourbuild
directory - In the
CMake Options
placeholder you can now insert-DCMAKE_BUILD_TYPE=Debug
reassuring that you will be inDebug
mode and any other options that you might need e.g-DTILEDB_SERIALIZATION=ON
accompanied with-DTILEDB_CMAKE_IDE=ON
needed for Code highlighting, syntax checking, etc.. - Let the Cmake build again the project
- Portions of code with
#ifdef TILEDB_SERIALIZATION
should now be reachable.
You can reload the project in CLion with Tools -> CMake -> Reset Cache and Reload Project
, but this step is optional and only for making sure that indeed works as it should.
It's possible to set up a Clion project to remote deploy / debug a project on external servers using your local Clion IDE. This is useful for building / deploying / testing on beefier servers on EC2 for instance.
See the JetBrains documentation on how to set this up: https://www.jetbrains.com/help/clion/remote-development.html
Note: It is still required to use the Clion superbuild workaround described above.