Commit 04f7adb6 authored by Ghislain MARY's avatar Ghislain MARY

Clean CMake builder.

parent 517c9814
......@@ -307,7 +307,7 @@ function(linphone_builder_get_autotools_configuration)
unset(_extra_generator)
unset(_generator)
include(${CMAKE_CURRENT_BINARY_DIR}/Autotools/Autotools.cmake)
endfunction(linphone_builder_get_autotools_configuration)
endfunction()
macro(linphone_builder_create_targets_list)
......@@ -329,7 +329,7 @@ macro(linphone_builder_create_targets_list)
else()
message(FATAL_ERROR "Invalid LINPHONE_BUILDER_TARGET '${LINPHONE_BUILDER_TARGET}'")
endif()
endmacro(linphone_builder_create_targets_list)
endmacro()
macro(linphone_builder_include_builder BUILDER)
......@@ -340,13 +340,13 @@ macro(linphone_builder_include_builder BUILDER)
list(APPEND LINPHONE_BUILDER_INCLUDED_BUILDERS ${BUILDER})
endif()
unset(_already_included)
endmacro(linphone_builder_include_builder)
endmacro()
macro(linphone_builder_add_builder_to_target TARGETNAME BUILDER)
linphone_builder_include_builder(${BUILDER})
add_dependencies(${TARGETNAME} EP_${BUILDER})
endmacro(linphone_builder_add_builder_to_target)
endmacro()
macro(linphone_builder_apply_flags)
......@@ -356,19 +356,19 @@ macro(linphone_builder_apply_flags)
set(CMAKE_CXX_FLAGS${BUILD_CONFIG} "${CMAKE_CXX_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_CPPFLAGS}")
set(AUTOTOOLS_C_FLAGS${BUILD_CONFIG} "${AUTOTOOLS_C_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_CPPFLAGS}")
set(AUTOTOOLS_CXX_FLAGS${BUILD_CONFIG} "${AUTOTOOLS_CXX_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_CPPFLAGS}")
endif(NOT "${LINPHONE_BUILDER_CPPFLAGS}" STREQUAL "")
endif()
if(NOT "${LINPHONE_BUILDER_CFLAGS}" STREQUAL "")
set(CMAKE_C_FLAGS${BUILD_CONFIG} "${CMAKE_C_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_CFLAGS}")
set(AUTOTOOLS_C_FLAGS${BUILD_CONFIG} "${AUTOTOOLS_C_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_CFLAGS}")
endif(NOT "${LINPHONE_BUILDER_CFLAGS}" STREQUAL "")
endif()
if(NOT "${LINPHONE_BUILDER_CXXFLAGS}" STREQUAL "")
set(CMAKE_CXX_FLAGS${BUILD_CONFIG} "${CMAKE_CXX_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_CXXFLAGS}")
set(AUTOTOOLS_CXX_FLAGS${BUILD_CONFIG} "{AUTOTOOLS_CXX_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_CXX_FLAGS}")
endif(NOT "${LINPHONE_BUILDER_CXXFLAGS}" STREQUAL "")
endif()
if(NOT "${LINPHONE_BUILDER_OBJCFLAGS}" STREQUAL "")
set(CMAKE_C_FLAGS${BUILD_CONFIG} "${CMAKE_C_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_OBJCFLAGS}")
set(AUTOTOOLS_OBJC_FLAGS${BUILD_CONFIG} "${AUTOTOOLS_OBJC_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_OBJCFLAGS}")
endif(NOT "${LINPHONE_BUILDER_OBJCFLAGS}" STREQUAL "")
endif()
if(NOT "${LINPHONE_BUILDER_LDFLAGS}" STREQUAL "")
# TODO: The two following lines should not be here
set(CMAKE_C_FLAGS${BUILD_CONFIG} "${CMAKE_C_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_LDFLAGS}")
......@@ -378,9 +378,9 @@ macro(linphone_builder_apply_flags)
set(CMAKE_MODULE_LINKER_FLAGS${BUILD_CONFIG} "${CMAKE_MODULE_LINKER_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_LDFLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS${BUILD_CONFIG} "${CMAKE_SHARED_LINKER_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_LDFLAGS}")
set(AUTOTOOLS_LINKER_FLAGS${BUILD_CONFIG} "${AUTOTOOLS_LINKER_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_LDFLAGS}")
endif(NOT "${LINPHONE_BUILDER_LDFLAGS}" STREQUAL "")
endforeach(BUILD_CONFIG)
endmacro(linphone_builder_apply_flags)
endif()
endforeach()
endmacro()
macro(linphone_builder_apply_cmake_flags_to_autotools_project PROJNAME)
......@@ -391,7 +391,7 @@ macro(linphone_builder_apply_cmake_flags_to_autotools_project PROJNAME)
if(NOT ${BUILD_TYPE_FOUND} EQUAL -1)
string(TOUPPER "${CMAKE_BUILD_TYPE}" UPPER_BUILD_TYPE)
set(BUILD_TYPE_SUFFIX "_${UPPER_BUILD_TYPE}")
endif(NOT ${BUILD_TYPE_FOUND} EQUAL -1)
endif()
set(ep_asflags "${AUTOTOOLS_AS_FLAGS${BUILD_TYPE_SUFFIX}}")
set(ep_cppflags "${AUTOTOOLS_CPP_FLAGS${BUILD_TYPE_SUFFIX}}")
set(ep_cflags "${AUTOTOOLS_C_FLAGS${BUILD_TYPE_SUFFIX}}")
......@@ -399,7 +399,7 @@ macro(linphone_builder_apply_cmake_flags_to_autotools_project PROJNAME)
set(ep_objcflags "${AUTOTOOLS_OBJC_FLAGS${BUILD_TYPE_SUFFIX}}")
set(ep_ldflags "${AUTOTOOLS_LINKER_FLAGS${BUILD_TYPE_SUFFIX}}")
endif()
endmacro(linphone_builder_apply_cmake_flags_to_autotools_project)
endmacro()
macro(linphone_builder_apply_extra_flags PROJNAME)
......@@ -414,18 +414,18 @@ macro(linphone_builder_apply_extra_flags PROJNAME)
foreach(BUILD_CONFIG "" "_DEBUG" "_MINSIZEREL" "_RELEASE" "_RELWITHDEBINFO")
if(NOT "${EP_${PROJNAME}_EXTRA_CFLAGS}" STREQUAL "")
set(CMAKE_C_FLAGS${BUILD_CONFIG} "${CMAKE_C_FLAGS${BUILD_CONFIG}} ${EP_${PROJNAME}_EXTRA_CFLAGS}")
endif(NOT "${EP_${PROJNAME}_EXTRA_CFLAGS}" STREQUAL "")
endif()
if(NOT "${EP_${PROJNAME}_EXTRA_CXXFLAGS}" STREQUAL "")
set(CMAKE_CXX_FLAGS${BUILD_CONFIG} "${CMAKE_CXX_FLAGS${BUILD_CONFIG}} ${EP_${PROJNAME}_EXTRA_CXXFLAGS}")
endif(NOT "${EP_${PROJNAME}_EXTRA_CXXFLAGS}" STREQUAL "")
endif()
if(NOT "${EP_${PROJNAME}_EXTRA_LDFLAGS}" STREQUAL "")
set(CMAKE_EXE_LINKER_FLAGS${BUILD_CONFIG} "${CMAKE_EXE_LINKER_FLAGS${BUILD_CONFIG}} ${EP_${PROJNAME}_EXTRA_LDFLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS${BUILD_CONFIG} "${CMAKE_MODULE_LINKER_FLAGS${BUILD_CONFIG}} ${EP_${PROJNAME}_EXTRA_LDFLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS${BUILD_CONFIG} "${CMAKE_SHARED_LINKER_FLAGS${BUILD_CONFIG}} ${EP_${PROJNAME}_EXTRA_LDFLAGS}")
endif(NOT "${EP_${PROJNAME}_EXTRA_LDFLAGS}" STREQUAL "")
endforeach(BUILD_CONFIG)
endforeach()
endif()
endmacro(linphone_builder_apply_extra_flags)
endmacro()
macro(linphone_builder_set_ep_directories PROJNAME)
......@@ -435,11 +435,11 @@ macro(linphone_builder_set_ep_directories PROJNAME)
set(ep_tmp "${ep_base}/tmp-${CONFIG_NAME}/${PROJNAME}")
if("${EP_${PROJNAME}_BUILD_IN_SOURCE}" STREQUAL "yes")
set(ep_build "${ep_source}")
else("${EP_${PROJNAME}_BUILD_IN_SOURCE}" STREQUAL "yes")
else()
set(ep_build "${ep_base}/Build-${CONFIG_NAME}/${PROJNAME}")
endif("${EP_${PROJNAME}_BUILD_IN_SOURCE}" STREQUAL "yes")
endif()
unset(CONFIG_NAME)
endmacro(linphone_builder_set_ep_directories)
endmacro()
macro(linphone_builder_create_autogen_command PROJNAME)
......@@ -448,13 +448,13 @@ macro(linphone_builder_create_autogen_command PROJNAME)
set(ep_autogen_options "")
foreach(OPTION ${EP_${PROJNAME}_CROSS_COMPILATION_OPTIONS} ${EP_${PROJNAME}_LINKING_TYPE} ${EP_${PROJNAME}_CONFIGURE_OPTIONS})
set(ep_autogen_options "${ep_autogen_options} \"${OPTION}\"")
endforeach(OPTION)
endforeach()
endif()
set(ep_autogen_command "${ep_source}/autogen.sh ${ep_autogen_options}")
else()
set(ep_autogen_command "")
endif()
endmacro(linphone_builder_create_autogen_command)
endmacro()
macro(linphone_builder_create_configure_command PROJNAME)
......@@ -464,11 +464,11 @@ macro(linphone_builder_create_configure_command PROJNAME)
set(ep_configure_options "")
foreach(OPTION ${EP_${PROJNAME}_CROSS_COMPILATION_OPTIONS} ${EP_${PROJNAME}_LINKING_TYPE} ${EP_${PROJNAME}_CONFIGURE_OPTIONS})
set(ep_configure_options "${ep_configure_options} \"${OPTION}\"")
endforeach(OPTION)
endforeach()
set(ep_configure_env "${EP_${PROJNAME}_CONFIGURE_ENV}")
set(ep_configure_command "${ep_source}/configure ${ep_configure_options}")
endif()
endmacro(linphone_builder_create_configure_command)
endmacro()
# this function invokes configure_file() for the project, using the default file if
......@@ -520,14 +520,14 @@ function(linphone_builder_add_project PROJNAME)
linphone_builder_create_configure_command(${PROJNAME})
if("${EP_${PROJNAME}_CONFIG_H_FILE}" STREQUAL "")
set(ep_config_h_file config.h)
else("${EP_${PROJNAME}_CONFIG_H_FILE}" STREQUAL "")
else()
set(ep_config_h_file ${EP_${PROJNAME}_CONFIG_H_FILE})
endif("${EP_${PROJNAME}_CONFIG_H_FILE}" STREQUAL "")
endif()
if("${EP_${PROJNAME}_INSTALL_TARGET}" STREQUAL "")
set(ep_install_target "install")
else("${EP_${PROJNAME}_INSTALL_TARGET}" STREQUAL "")
else()
set(ep_install_target "${EP_${PROJNAME}_INSTALL_TARGET}")
endif("${EP_${PROJNAME}_INSTALL_TARGET}" STREQUAL "")
endif()
set(ep_redirect_to_file "2>&1 >> ${CMAKE_CURRENT_BINARY_DIR}/EP_${PROJNAME}.log")
if(WIN32)
......@@ -550,9 +550,9 @@ function(linphone_builder_add_project PROJNAME)
if("${EP_${PROJNAME}_PKG_CONFIG}" STREQUAL "")
set(LINPHONE_BUILDER_PKG_CONFIG "${PKG_CONFIG_PROGRAM}")
else("${EP_${PROJNAME}_PKG_CONFIG}" STREQUAL "")
else()
set(LINPHONE_BUILDER_PKG_CONFIG "${EP_${PROJNAME}_PKG_CONFIG}")
endif("${EP_${PROJNAME}_PKG_CONFIG}" STREQUAL "")
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/configure.sh.cmake ${CMAKE_CURRENT_BINARY_DIR}/EP_${PROJNAME}_configure.sh)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/build.sh.cmake ${CMAKE_CURRENT_BINARY_DIR}/EP_${PROJNAME}_build.sh)
......@@ -603,7 +603,6 @@ function(linphone_builder_add_project PROJNAME)
if(NOT "${EP_${PROJNAME}_RPMBUILD_OPTIONS}" STREQUAL "")
set(LINPHONE_BUILDER_RPMBUILD_OPTIONS "${EP_${PROJNAME}_RPMBUILD_OPTIONS}")
endif()
set(LINPHONE_BUILDER_SPEC_PREFIX "${EP_${PROJNAME}_SPEC_PREXIX}")
......@@ -613,13 +612,11 @@ function(linphone_builder_add_project PROJNAME)
set(LINPHONE_BUILDER_PKG_CONFIG "${EP_${PROJNAME}_PKG_CONFIG}")
endif()
if(NOT "${EP_${PROJNAME}_CONFIGURE_EXTRA_CMD}" STREQUAL "")
set(LINPHONE_BUILDER_CONFIGURE_EXTRA_CMD "${EP_${PROJNAME}_CONFIGURE_EXTRA_CMD}")
endif()
# allow to have special command steps
linphone_builder_configure_file_for_project(${PROJNAME} CONFIGURE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/configure.rpm.sh.cmake ${CMAKE_CURRENT_BINARY_DIR}/EP_${PROJNAME}_configure_rpm.sh)
linphone_builder_configure_file_for_project(${PROJNAME} BUILD ${CMAKE_CURRENT_SOURCE_DIR}/cmake/build.rpm.sh.cmake ${CMAKE_CURRENT_BINARY_DIR}/EP_${PROJNAME}_build_rpm.sh)
linphone_builder_configure_file_for_project(${PROJNAME} INSTALL ${CMAKE_CURRENT_SOURCE_DIR}/cmake/install.rpm.sh.cmake ${CMAKE_CURRENT_BINARY_DIR}/EP_${PROJNAME}_install_rpm.sh)
......@@ -640,7 +637,7 @@ function(linphone_builder_add_project PROJNAME)
if(LINPHONE_BUILDER_EXTERNAL_SOURCE_PATH)
foreach(SUBDIR ${EP_${PROJNAME}_EXTERNAL_SOURCE_PATHS})
if(NOT EP_${PROJNAME}_SOURCE_DIR)
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${LINPHONE_BUILDER_EXTERNAL_SOURCE_PATH}/${SUBDIR}")
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${LINPHONE_BUILDER_EXTERNAL_SOURCE_PATH}/${SUBDIR}/CMakeLists.txt")
set(EP_${PROJNAME}_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${LINPHONE_BUILDER_EXTERNAL_SOURCE_PATH}/${SUBDIR}")
endif()
endif()
......@@ -687,10 +684,10 @@ function(linphone_builder_add_project PROJNAME)
)
endif()
endfunction(linphone_builder_add_project)
endfunction()
function(linphone_builder_add_external_projects)
foreach(BUILDER ${LINPHONE_BUILDER_INCLUDED_BUILDERS})
linphone_builder_add_project(${BUILDER})
endforeach(BUILDER)
endfunction(linphone_builder_add_external_projects)
endforeach()
endfunction()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment