[CMake] Variable setting as a stack rather than as a blackboard?

Mike Jackson imikejackson at gmail.com
Fri Mar 7 16:23:38 EST 2008


I put

SET (LIBRARY_OUTPUT_PATH "${PROJECT_BINARY_DIR}/Bin" CACHE INTERNAL  
"For libraries.")
SET (EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/Bin" CACHE  
INTERNAL "For executables.")

at the top of all my top level CMakeLists.txt files. That has the  
ramification that every library or executable being built will be put  
into the same directory. I can live with that.


--
Mike Jackson
imikejackson & gmail * com




On Mar 7, 2008, at 4:19 PM, Christian Convey wrote:

> I have a problem:  In my multi-level source tree, I have some
> subprojects.  All subprojects are built by CMake.
>
> My problem is that sometimes a subproject (over which I have little
> control) sets a variable for its own use, such as LIBRARY_OUTPUT_PATH.
>  The problem is that the value gets cached, and then it hoses up other
> subprojects that are descended into later in the cmake processing.
>
> Has anyone considered extending CMake to permit variables to be
> treated as if on a stack, similar to what OpenGL does with
> transformation matrices?
>
> I'm envisioning something like this:
>
> subprojectA/CMakeLists.txt:
>     push_var(EXECUTABLE_OUTPUT_PATH, "subprojectA-bin-directory")
>
>     // popping vars is automatic when cmake leaves this  
> cmakelists.txt file
>
> subprojectB/CMakeLists.txt:
>     push_var(EXECUTABLE_OUTPUT_PATH, "subprojectB-bin-directory")
>
> subprojectC/CMakeLists.txt:
>     // doesn't explicitly set EXECUTABLE_OUTPUT_PATH
>
>
> toplevel/CMakeLists.txt
>    set(EXECUTABLE_OUTPUT_PATH, project-default-bin-dir)
>    add_subdirectory(subprojectA)
>    add_subdirectory(subprojectB)
>    add_subdirectory(subprojectC)
>
> The idea here is that when CMake gets around to processing
> subprojectC, subprojectC will start out with EXECUTABLE_OUTPUT_PATH
> having a value of "project-default-bin-dir", rather than
> "subprojectB-bin-directory".
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake



More information about the CMake mailing list