Bug #2293

libraries target naming in cmake

Added by Aleksei Iupinov almost 3 years ago. Updated almost 2 years ago.

build system
Target version:
Affected version - extra info:
Affected version:


While fixing GMX_CLANG_CUDA postsubmit being broken after libgpu_utilstest introduction in I9367d0f996de04c21312cef2081cc08148f80561,
I became aware of the fact that the cmake target libgpu_utilstest actually leads to the creation of the file named
Another "lib" gets prepended automatically by cmake itself. Confused, I looked at libgromacs target, and discovered it gets renamed with

set_target_properties(libgromacs PROPERTIES
                      OUTPUT_NAME "gromacs${GMX_LIBS_SUFFIX}" 
                      <more properties...>

Was it a conscious decision to make the library target name(s) stand out only to "erase" lib prefix later?
Should libgpu_utilstest follow same approach?

Associated revisions

Revision a67a6b0e (diff)
Added by Aleksei Iupinov almost 3 years ago

Make gpu_utils-test build with GMX_CLANG_CUDA

Same workarounds are applied to libgpu_utilstest as for libgromacs.
Renamed ligbpu_utilstest target to gpu_utilstest_cuda to avoid the
double "lib" prefix in the filename.

Refs #2259, #2293

Change-Id: I16b07a13ce2dca30079a889e2b314483d82d3674


#1 Updated by Aleksei Iupinov almost 3 years ago

As Paul comments on Gerrit, it's also possible to overwrite default "lib" prefix with PROPERTIES PREFIX ""

#2 Updated by Mark Abraham almost 3 years ago

I don't know, but we can also look at the git history to see if there are any clues present when it was introduced.

Naturally it's nice to have a target called libgromacs, and to build a library of the same name, but if a tool prepends a "lib" to the target name, then some hack like this is all you can do. Ideally there'd be a way to seaparate the target name from the library name.

#3 Updated by Szilárd Páll almost 3 years ago

As I noted somewhere (perhaps irl), I have a vague memory that this was perhaps a hack to make Windows libraries be called "libgromacs", but I may be making that up.

I can try to do a bit more of git archeology later when the usual rush-and-stress is over.

#4 Updated by Szilárd Páll almost 3 years ago

BTW, interestingly, there is no sign of it in v4.6 (did git grep 'add_library'), so there's a good chance there won't be a need to look at CMake fossils from a billion years ago.

#5 Updated by Erik Lindahl almost 3 years ago

  • Target version set to 2019

Libraries on Windows typically don't have prefixes, and on Unix the prefix is not considered part of the name (that's why the prefix is not included in linker flags).

Unless there is any pressing reason, I suggest we simply rename it to "gromacs" for release-2019.

#6 Updated by Mark Abraham almost 2 years ago

  • Status changed from New to Closed

Nobody's prioritised this for 2019, and it's not something that we should spend time on in future.

Also available in: Atom PDF