diff options
Diffstat (limited to 'source/CMakeLists.txt')
-rw-r--r-- | source/CMakeLists.txt | 103 |
1 files changed, 60 insertions, 43 deletions
diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index f23af477bf89..d031be940cb4 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -25,29 +25,72 @@ set(lldbBase_SOURCES lldb.cpp ) -if (CMAKE_SYSTEM_NAME MATCHES "Darwin") - set(LLDB_VERS_GENERATED_FILE ${LLDB_BINARY_DIR}/source/LLDB_vers.c) - add_custom_command(OUTPUT ${LLDB_VERS_GENERATED_FILE} - COMMAND ${LLDB_SOURCE_DIR}/scripts/generate-vers.pl - ${LLDB_SOURCE_DIR}/lldb.xcodeproj/project.pbxproj liblldb_core - > ${LLDB_VERS_GENERATED_FILE} - DEPENDS ${LLDB_SOURCE_DIR}/scripts/generate-vers.pl - ${LLDB_SOURCE_DIR}/lldb.xcodeproj/project.pbxproj) - set_source_files_properties(${LLDB_VERS_GENERATED_FILE} PROPERTIES GENERATED 1) - # Add this to lldbBase since lldb.cpp uses the symbol defined here. - list(APPEND lldbBase_SOURCES ${LLDB_VERS_GENERATED_FILE}) - add_custom_target(lldbGeneratedVersion - DEPENDS ${LLDB_VERS_GENERATED_FILE}) +foreach(file + "${LLDB_SOURCE_DIR}/.git/logs/HEAD" # Git + "${LLDB_SOURCE_DIR}/.svn/wc.db" # SVN 1.7 + "${LLDB_SOURCE_DIR}/.svn/entries" # SVN 1.6 + ) + if(EXISTS "${file}") + set(lldb_vc "${file}") + break() + endif() +endforeach() + +if(DEFINED lldb_vc) + set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/SVNVersion.inc") + set(get_svn_script "${LLVM_CMAKE_PATH}/GetSVN.cmake") + + # Create custom target to generate the VC revision include. + add_custom_command(OUTPUT "${version_inc}" + DEPENDS "${lldb_vc}" "${get_svn_script}" + COMMAND + ${CMAKE_COMMAND} "-DFIRST_SOURCE_DIR=${LLDB_SOURCE_DIR}" + "-DFIRST_NAME=LLDB" + "-DHEADER_FILE=${version_inc}" + -P "${get_svn_script}") + + # Mark the generated header as being generated. + set_source_files_properties("${version_inc}" + PROPERTIES GENERATED TRUE + HEADER_FILE_ONLY TRUE) + + # Tell Version.cpp that it needs to build with -DHAVE_SVN_VERSION_INC. + set_property(SOURCE lldb.cpp APPEND PROPERTY + COMPILE_DEFINITIONS "HAVE_SVN_VERSION_INC") + list(APPEND lldbBase_SOURCES ${version_inc}) +endif() + +if(APPLE) + set(apple_version_inc "${CMAKE_CURRENT_BINARY_DIR}/AppleVersion.inc") + set(apple_version_script "${LLDB_SOURCE_DIR}/cmake/modules/EmbedAppleVersion.cmake") + set(info_plist ${LLDB_SOURCE_DIR}/resources/LLDB-Info.plist) + + # Create custom target to generate the VC revision include. + add_custom_command(OUTPUT "${apple_version_inc}" + DEPENDS "${apple_version_script}" "${info_plist}" + COMMAND + ${CMAKE_COMMAND} "-DLLDB_INFO_PLIST=${info_plist}" + "-DHEADER_FILE=${apple_version_inc}" + -P "${apple_version_script}") + + # Mark the generated header as being generated. + set_source_files_properties("${apple_version_inc}" + PROPERTIES GENERATED TRUE + HEADER_FILE_ONLY TRUE) + + # Tell Version.cpp that it needs to build with -DHAVE_SVN_VERSION_INC. + set_property(SOURCE lldb.cpp APPEND PROPERTY + COMPILE_DEFINITIONS "HAVE_APPLE_VERSION_INC") + list(APPEND lldbBase_SOURCES ${apple_version_inc}) +elseif(LLDB_VERSION_STRING) + set_property(SOURCE lldb.cpp APPEND PROPERTY + COMPILE_DEFINITIONS "LLDB_VERSION_STRING=${LLDB_VERSION_STRING}") endif() add_lldb_library(lldbBase ${lldbBase_SOURCES} ) -if (CMAKE_SYSTEM_NAME MATCHES "Darwin") - add_dependencies(lldbBase lldbGeneratedVersion) -endif() - add_subdirectory(Breakpoint) add_subdirectory(Commands) add_subdirectory(Core) @@ -64,29 +107,3 @@ add_subdirectory(Utility) # Build API last. Since liblldb needs to link against every other target, it needs # those targets to have already been created. add_subdirectory(API) - -# Determine LLDB revision and repository. GetSourceVersion and GetRepositoryPath are shell-scripts, and as -# such will not work on Windows. -if ( NOT CMAKE_SYSTEM_NAME MATCHES "Windows" ) - execute_process(COMMAND ${CMAKE_SOURCE_DIR}/utils/GetSourceVersion ${LLDB_SOURCE_DIR} - OUTPUT_VARIABLE LLDB_REVISION) - if ( LLDB_REVISION ) - string(REGEX REPLACE "(\r?\n)+$" "" LLDB_REVISION ${LLDB_REVISION}) - endif() - - execute_process(COMMAND ${CMAKE_SOURCE_DIR}/utils/GetRepositoryPath ${LLDB_SOURCE_DIR} - OUTPUT_VARIABLE LLDB_REPOSITORY) - if ( LLDB_REPOSITORY ) - # Replace newline characters with spaces - string(REGEX REPLACE "(\r?\n)+" " " LLDB_REPOSITORY ${LLDB_REPOSITORY}) - - # Remove trailing spaces - string(REGEX REPLACE "(\ )+$" "" LLDB_REPOSITORY ${LLDB_REPOSITORY}) - endif() - - set_property( - SOURCE lldb.cpp - PROPERTY COMPILE_DEFINITIONS "LLDB_REVISION=\"${LLDB_REVISION}\"" "LLDB_REPOSITORY=\"${LLDB_REPOSITORY}\"") -endif () -# FIXME: implement svn/git revision and repository parsing solution on Windows. There is an SVN-only -# revision parsing solution in tools/clang/lib/Basic/CMakelists.txt. |