1
$\begingroup$

I need to build several independent "variants" of Blender (differently modified sources for the same target platform) and would like to use the same "lib" folder for all of them. I cannot place them in the same "root" folder with the lib folder (the usual folder structure).

Essentially, I would like to have something like this:

MyBlenderDEVroot  
   lib               <- this is where I'd like to have lib folder
   Variant1
      blender        <- Blender sources
      builds         <- build output folder
      mydocs
      mystuff
   Variant2
      blender        <- Blender sources
      builds         <- build output folder
      mydocs
      mystuff

I know that I can have differently named "blender" and "builds" folders (like blender_v1, builds_v1, blender_v2, builds_v2, etc.) in the same root but I want them fully separated.

I am targeting Windows and I use VS2013 with CMake.
I have no problems building Blender the "normal" way, just would like to avoid having the same mutli-GB lib folder repeated all over the place.

$\endgroup$
2
$\begingroup$

OK, I figured it out my self.

There are couple of lines in CMakeLists.txt that set the path to the lib folder one level relative to the source files folder (carried by the CMAKE_SOURCE_DIR variable).
To make it work with my example folder structure simply adding one more level solved the problem:

    if(NOT DEFINED LIBDIR)
        # Setup 64bit and 64bit windows systems
        if(CMAKE_CL_64)
            message(STATUS "64 bit compiler detected.")
            set(LIBDIR ${CMAKE_SOURCE_DIR}/../../lib/win64_vc12)
        else()
            message(STATUS "32 bit compiler detected.")
            set(LIBDIR ${CMAKE_SOURCE_DIR}/../../lib/windows_vc12)
        endif()
    else()
        message(STATUS using LIBDIR  ${LIBDIR})
    endif()

My real folder structure was a bit more complex and the common lib location was off the branch with sources so I made it a bit more complicated:

    # added this near the top of CMakeLists.txt for easy reference
    if(WIN32)
        set(COMMON_LIBPATH "C:/some_complex_path/CommonStuff/Blender/lib")
    endif()

    ...

    if(NOT DEFINED LIBDIR)
        # Setup 64bit and 64bit windows systems
        if(CMAKE_CL_64)
            message(STATUS "64 bit compiler detected.")
            if(COMMON_LIBPATH)
                message(STATUS "Using common lib path: " ${COMMON_LIBPATH})
                set(LIBDIR ${COMMON_LIBPATH}/../lib/win64_vc12)
            else()
                set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/win64_vc12)
            endif()
        else()
            message(STATUS "32 bit compiler detected.")
            if(COMMON_LIBPATH)
                message(STATUS "Using common lib path: " ${COMMON_LIBPATH})
                set(LIBDIR ${COMMON_LIBPATH}/../lib/windows_vc12)
            else()
                set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/windows_vc12)
            endif()
        endif()
    else()
        message(STATUS using LIBDIR  ${LIBDIR})
    endif()

You have to edit the CMakeLists.txt file in each source code folder (e.g. the standard "blender" folder).

As I am targeting Windows this applies to, you guessed it, Windows.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.