Repository: conan-io/conan-center-index

Issue:
[pagmo2] pagmo2/2.10: does not link eigen and nlopt properly when setting options to True
<!-- 
  Please don't forget to update the issue title.
  Include all applicable information to help us reproduce your problem.
-->

### Package and Environment Details (include every applicable attribute)
  * Package Name/Version: **pagmo2/2.10**
  * Operating System+version: **Linux Ubuntu 18.04**
  * Compiler+version: **GCC 7**
  * Conan version: **conan 1.46.2**
  * Python version: **Python 3.6.9**


### Conan profile (output of `conan profile show default` or `conan profile show <profile>` if custom profile is in use)
```
Configuration for profile default:

[settings]
os=Linux
os_build=Linux
arch=x86_64
arch.march=None
arch_build=x86_64
compiler=gcc
compiler.version=7
compiler.libcxx=libstdc++11
build_type=Release
[options]
[conf]
[build_requires]
[env]
```


### Steps to reproduce (Include if Applicable)
1) create package with options `-o pagmo2:with_eigen=True` and `-o pagmo2:with_nlopt=True` (it will be created without errors)
2) In another project include `pagmo2/2.10` as requirement and include a header like `<pagmo/algorithms/xnes.hpp>`

### Logs (Include/Attach if Applicable)
<details><summary>Click to expand log</summary>

```
Put your log output here
```

</details>



Discussion:
If it builds without error, given the logic in https://github.com/esa/pagmo2/blob/v2.10/CMakeLists.txt and that pagmo2/2.10 is header only, what is the issue exactly?
Actually I tested it again, and the error did not occur anymore. I think I might have set the options wrongly. Sorry for the confusion :see_no_evil: 
Closing this issue and the PR.
@SpaceIm Reopening because I found the real problem: the pagmo2/2.10 specifies `self.info.header_only()` but while it technically is header only, there is the (cmake) option to turn on eigen/nlopt/ipopt support.
Setting it to header only in the `package_id()` function enforces it to have the same package id all the time, and switching the options would basically just overwrite the package created.

In our system the automatic release with the build matrix then only uploads the package with options turned off, causing the following error when using pagmo2 in another project.
```
error: #error The xnes.hpp header was included, but pagmo was not compiled with eigen3 support
 #error The xnes.hpp header was included, but pagmo was not compiled with eigen3 support
```

What would be the best way to solve this problem?
Correct, `config.hpp` content depends on these options.

The fix is to replace `self.info.header_only()` by `self.info.settings.clear()`.

Resolving patch:
diff --git a/recipes/pagmo2/pre_2.11/conanfile.py b/recipes/pagmo2/pre_2.11/conanfile.py
--- a/recipes/pagmo2/pre_2.11/conanfile.py
+++ b/recipes/pagmo2/pre_2.11/conanfile.py
@@ -61,7 +61,7 @@ def validate(self):
             raise ConanInvalidConfiguration("{0} requires non header-only boost with these components: {1}".format(self.name, ", ".join(self._required_boost_components)))
 
     def package_id(self):
-        self.info.header_only()
+        self.info.settings.clear()
 
     def source(self):
         tools.get(**self.conan_data["sources"][self.version],


Test patch: