Just to clarify, my suggestion was assuming that each build only produces
either static or shared libraries, not both.

Given that assumption, wouldn't it be better to define targets using a
single name (without `_static` or `_shared` suffix), and decide in one
place whether that target is defined as STATIC or SHARED depending on the
`ARROW_BUILD_SHARED`?

That way, we wouldn't need to switch on `ARROW_BUILD_SHARED` repeatedly to
determine which target name to link.

On 2025/06/03 06:05:45 Sutou Kouhei wrote:
> Hi,
>
> Do you want a CMake target that can be used for shared
> linking and static linking? For example, you want to use
> Parquet::parquet for shared linking and static linking,
> right?
>
> In my understanding, we can't do it with CMake. We need to
> specify "SHARED" or "STATIC" when create a CMake target by
> add_library().
> See also:
> https://cmake.org/cmake/help/latest/command/add_library.html#normal
>
> Thanks,
> --
> kou
>
> In <ca...@mail.gmail.com>
>   "[C++] Static/Shared Linkage in CMakeLists.txt" on Tue, 3 Jun 2025
13:45:36 +0800,
>   Eddie Chang <ka...@gmail.com> wrote:
>
> > Hello everyone, I've noticed that in our CMakeLists.txt files, we have
> > multiple instances where we conditionally select either the static or
> > shared version of a linked target based on a cache variable such as
> > ARROW_BUILD_SHARED. For example, the following pattern appears in
several
> > places:
> >
> >     if(ARROW_BUILD_SHARED)
> >         set(PARQUET_EXAMPLE_LINK_LIBS parquet_shared)
> >     else()
> >         set(PARQUET_EXAMPLE_LINK_LIBS parquet_static)
> >     endif()
> >
> > I’m wondering if there is a specific reason we don’t set the
static/shared
> > property of the libraries in a single location, and instead continue
> > duplicating this kind of logic throughout the codebase?
>

Reply via email to