Commit 429ef469 authored by Jan Koester's avatar Jan Koester
Browse files

some cmake fixes

parent 49e478f5
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -8,7 +8,9 @@ if(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64")
    )
endif()

function (build_section name stage sourcedir builddir stagedir configargs buildargs)
cmake_host_system_information(RESULT jobs QUERY "NUMBER_OF_LOGICAL_CORES")

function (build_section name stage sourcedir builddir stagedir configargs buildargs depends)
    file(MAKE_DIRECTORY ${builddir})
    add_custom_target(
        "${stage}_${name}_configure" ALL
@@ -21,7 +23,7 @@ function (build_section name stage sourcedir builddir stagedir configargs builda
    )
    add_custom_target(
        "${stage}_${name}_build" ALL
        COMMAND ${CMAKE_COMMAND} ${buildargs} --build ${builddir}
        COMMAND ${CMAKE_COMMAND} ${buildargs} --build ${builddir} -j ${jobs}
        WORKING_DIRECTORY ${builddir}
    )
    add_custom_target(
@@ -29,13 +31,25 @@ function (build_section name stage sourcedir builddir stagedir configargs builda
        COMMAND ${CMAKE_COMMAND} --install ${builddir}
        WORKING_DIRECTORY ${builddir}
    )
    if(${depends})
        add_dependencies("${stage}_${name}_configure" "${stage}_${depends}_install")
    endif()
    add_dependencies("${stage}_${name}_build" "${stage}_${name}_configure")
    add_dependencies("${stage}_${name}_install" "${stage}_${name}_build")
    add_dependencies("stage_${stage}" "${stage}_${name}_install")
    if(${stage} GREATER 1)
        math(EXPR bef_stage "${stage}-1")
        add_dependencies("${stage}_${name}_configure" stage_${bef_stage})
    endif()
endfunction()

add_subdirectory(thirdparty)
add_subdirectory(libs)

add_custom_target(stage_1 ALL)
add_custom_target(stage_2 ALL DEPENDS stage_1)
add_custom_target(stage_3 ALL DEPENDS stage_3)

set(STAGE 1)
set(STAGE_DIR "${CMAKE_BINARY_DIR}/stage1")
build_thirdparty()
+2 −1
Original line number Diff line number Diff line
function(build_libs)
    build_section(
        ${STAGE} 
        "libsystempp"
        ${STAGE} 
        "${CMAKE_SOURCE_DIR}/libs/libsystempp" 
        "${STAGE_DIR}/build/libsystempp" 
        ${STAGE_DIR}
        ""
        ""
        "llvm"
    )
endfunction()
+6 −1
Original line number Diff line number Diff line
function(build_thirdparty)
    build_section(
        ${STAGE} 
        "googletest"
        ${STAGE} 
        "${CMAKE_SOURCE_DIR}/thirdparty/googletest" 
        "${STAGE_DIR}/build/googletest" 
        ${STAGE_DIR}
        ""
        ""
        "libsystempp"
    )
    build_section(
        "abseil-cpp"
@@ -16,6 +17,7 @@ function(build_thirdparty)
        ${STAGE_DIR}
        "-DABSL_USE_EXTERNAL_GOOGLETEST=ON -DABSL_LOCAL_GOOGLETEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}/googletest"
        ""
        "googletest"
    )
    build_section(
        "ninja-build"
@@ -25,6 +27,8 @@ function(build_thirdparty)
        ${STAGE_DIR}
        "-B${STAGE_DIR}/build/ninja-build " 
        ""
        ""
        ""
    )
    
    build_section(
@@ -35,5 +39,6 @@ function(build_thirdparty)
        ${STAGE_DIR}
        "" 
        ""
        ""
    )
endfunction()