cmlib/CMLibOrganizationName.cmake

20 lines
709 B
CMake
Raw Normal View History

2019-02-12 16:31:17 +00:00
# read file cmake/etc/organization.txt and set global property ORGANIZATION_NAME
function(set_organization_name)
set(_organization_file "${CMAKE_SOURCE_DIR}/cmake/etc/organization.txt")
if(NOT EXISTS "${_organization_file}")
message(FATAL_ERROR "File ${ORGANIZATION_FILE} doesn't exist")
endif()
file(READ "${_organization_file}" _org)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${_organization_file})
if(NOT "${_org}" MATCHES "^([0-9A-Za-z ,.]+)\n")
message(FATAL_ERROR "File ${_organization_file} has wrong format")
endif()
string(REGEX MATCH "^([0-9A-Za-z ,.]+)\n" _ ${_org})
set_property(GLOBAL PROPERTY ORGANIZATION_NAME ${CMAKE_MATCH_1})
endfunction()