I was building PIO and was only getting static libraries and my program (ESMF) failed to link. The link order was incorrect for static linking, but I was assuming shared libraries would be built by default.
The CMake variable BUILD_SHARED_LIBS is used to control this, but it's not given a default value in the CMakeLIsts.txt. By setting it explicitly on the command line with -DBUILD_SHARED_LIBS=ON I was able to build shared libraries.
As noted in the documentation:
This variable is often added to projects as an option() so that each user of a project can decide if they want to build the project using shared or static libraries.
I think BUILD_SHARED_LIBS should be an option in CMakeLists.txt and given a default value of ON. The strange thing is I didn't see this behavior before. I'm not sure if it's my CMake version (3.23.2) that defaults it to off when it was on before, but regardless I think it should be explicit.
I was building PIO and was only getting static libraries and my program (ESMF) failed to link. The link order was incorrect for static linking, but I was assuming shared libraries would be built by default.
The CMake variable
BUILD_SHARED_LIBS
is used to control this, but it's not given a default value in the CMakeLIsts.txt. By setting it explicitly on the command line with-DBUILD_SHARED_LIBS=ON
I was able to build shared libraries.As noted in the documentation:
I think
BUILD_SHARED_LIBS
should be anoption
in CMakeLists.txt and given a default value ofON
. The strange thing is I didn't see this behavior before. I'm not sure if it's my CMake version (3.23.2) that defaults it to off when it was on before, but regardless I think it should be explicit.