Create symlink to a install result

├── build
│ └── lib
│ └──
└── package
├── fixed
│ └── dir
│ └── structure
│ └──
└── lib

I don’t have much experience on writing CMakeLists. I have a project where I want to create a symlink that points to “package/lib/”, and this needs to be done in a different CMakeLists.txt from the one for the target foo.

Some question:

  1. how to ensure the order? The has to be installed before symlink.
  2. how to create symlink? I think add_custom_target can help on this?

Not sure that matters, but just make sure the directory installing is add_subdirectory’d before the install() for the symlink is performed.

You can use install(CODE) or install(SCRIPT) to run CMake code at install time. There, you can use file(CREATE_LINK … SYMBOLIC).