CDZ
CDZ

Reputation: 853

cmake, missing feature set_directory_property?

I have a cmake project and I want to do the following :

set_directory_property(DIRECTORY glfw BUILD_SHARED_LIBS ON)
add_subdirectory(glfw)

I want to force the BUILD_SHARED_LIBS to be ON, but only in the scope of the 'glfw' sub directory. Without touching the glfw cmake files.

Is it possible ?

There is no set_directory_property, only a get_directory_property :-(

Thanks

Upvotes: 0

Views: 204

Answers (2)

CDZ
CDZ

Reputation: 853

I found a solution, I had to use the following :

set(BUILD_SHARED_LIBS ON CACHE "" INTERNAL FORCE)
add_subdirectory(glfw)
set(BUILD_SHARED_LIBS OFF CACHE "" INTERNAL FORCE)

Thanks for your help !

Upvotes: 0

Florian
Florian

Reputation: 43030

The BUILD_SHARED_LIBS is a variable not a directory property. And the VARIABLES directory property is read-only.

So in your case you just do:

set(BUILD_SHARED_LIBS ON)
add_subdirectory(glfw)
unset(BUILD_SHARED_LIBS)

Upvotes: 2

Related Questions