Skip to content

Commit

Permalink
Make CLion's CMake Preset Integration work with Conan.
Browse files Browse the repository at this point in the history
  • Loading branch information
PengZheng committed Aug 25, 2023
1 parent 9763b61 commit cf69e33
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
11 changes: 5 additions & 6 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class CelixConan(ConanFile):
"celix_err_buffer_size": ["ANY"],
}
default_options = {
"celix_err_buffer_size": 512,
"celix_err_buffer_size": "512",
}

for comp in _celix_defaults.keys():
Expand Down Expand Up @@ -414,18 +414,17 @@ def generate(self):
lst = [x.ref.name for x in self.requires.values()]
if "mdnsresponder" in lst:
tc.cache_variables["BUILD_ERROR_INJECTOR_MDNSRESPONDER"] = "ON"
tc.cache_variables["CELIX_ERR_BUFFER_SIZE"] = self.options.celix_err_buffer_size
tc.cache_variables["CELIX_ERR_BUFFER_SIZE"] = str(self.options.celix_err_buffer_size)
# tc.cache_variables["CMAKE_PROJECT_Celix_INCLUDE"] = os.path.join(self.build_folder, "conan_paths.cmake")
# the following is workaround for https://github.com/conan-io/conan/issues/7192
if self.settings.os == "Linux":
tc.cache_variables["CMAKE_EXE_LINKER_FLAGS"] = "-Wl,--unresolved-symbols=ignore-in-shared-libs"
elif self.settings.os == "Macos":
tc.cache_variables["CMAKE_EXE_LINKER_FLAGS"] = "-Wl,-undefined -Wl,dynamic_lookup"
v = Version(self.version)
tc.cache_variables["CELIX_MAJOR"] = v.major.value
tc.cache_variables["CELIX_MINOR"] = v.minor.value
tc.cache_variables["CELIX_MICRO"] = v.patch.value
tc.user_presets_path = False
tc.cache_variables["CELIX_MAJOR"] = str(v.major.value)
tc.cache_variables["CELIX_MINOR"] = str(v.minor.value)
tc.cache_variables["CELIX_MICRO"] = str(v.patch.value)
tc.generate()

def _configure_cmake(self):
Expand Down
8 changes: 4 additions & 4 deletions documents/building/dev_celix_with_clion.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ conan profile new default --detect
conan profile new debug --detect
conan profile update settings.build_type=Debug debug

#generate and configure cmake-build-debug directory
# Generate and configure cmake-build-debug directory
# If CLion's CMake Preset Integration has been enabled, then CLion will load available CMake profiles
# from the CMakeUserPresets.json file at the project root, which is generated by `conan install`.
conan install . celix/2.3.0 -pr:b default -pr:h debug -if cmake-build-debug/ -o celix:enable_testing=True -o celix:enable_address_sanitizer=True -o celix:build_all=True -b missing

# optional build
# If you want to skip building, which may take long, you can copy the the exact CMAKE command `conan install` shows into CLion
# and let CLion perform build directory configuration and build.
#optional build
conan build . -bf cmake-build-debug/

#optional setup run env and run tests
Expand Down

0 comments on commit cf69e33

Please sign in to comment.