I'm using a global variable in cmake using CACHE STRING FORCE
trick..
I want this simple test case to work messaging in the end only "dudee" and not "dudeedudee:
cmake_minimum_required(VERSION 2.8.10)
set(DUDEE "dudee")
set(LIB ${DUDEE} CACHE STRING "Description" FORCE)
set(LIB ${LIB} ${DUDEE} CACHE STRING "Description" FORCE)
message(${LIB})
Little explanation: Ok, I know that it is not nice to use global variable but cmake is kind of hell but I cannot track down the scope so PARENT
can not work and I have a nice working example in which I set dependencies between different cmake modules and application that I wrote with global variable and it works.
But.. sometimes it happens that some modules call each other and each one is adding the dependencies.. a simple example:
application XXX uses the modules VideoReader, BlobDetector, VideoViewer, BlobTracker. All of those modules import the OpenCV libs dependecies in this way:
set(LIB ${LIB} ${OpenCV_LIBS} CACHE STRING "Description" FORCE)
and in the end I have the opencv libs a lot of time repeated in the ${LIB}
variable