aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorredfish <redfish@galactica.pw>2017-10-20 22:07:34 -0400
committerredfish <redfish@galactica.pw>2017-10-20 22:07:34 -0400
commit11e0deef31a0361430d3d68f6f90e5c40a956d71 (patch)
tree5471888b9fbbc4853dddde8c7b2994178895b9a4 /src
parent.gitignore: do not ignore cmake source files (diff)
downloadmonero-11e0deef31a0361430d3d68f6f90e5c40a956d71.tar.xz
cmake: add dep of version lib on version.cpp
Also, move cmake source files into cmake/ to keep them together.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt28
-rw-r--r--src/version.cmake63
2 files changed, 16 insertions, 75 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 6fb08b645..0281b1df6 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -83,26 +83,30 @@ function (monero_add_executable name)
endfunction ()
function (monero_add_library name)
- source_group("${name}"
- FILES
- ${ARGN})
+ monero_add_library_with_deps(NAME "${name}" SOURCES ${ARGN})
+endfunction()
+
+function (monero_add_library_with_deps)
+ cmake_parse_arguments(MONERO_ADD_LIBRARY "" "NAME" "DEPENDS;SOURCES" ${ARGN})
+ source_group("${MONERO_ADD_LIBRARY_NAME}" FILES ${MONERO_ADD_LIBRARY_SOURCES})
# Define a ("virtual") object library and an actual library that links those
# objects together. The virtual libraries can be arbitrarily combined to link
# any subset of objects into one library archive. This is used for releasing
# libwallet, which combines multiple components.
- set(objlib obj_${name})
- add_library(${objlib} OBJECT ${ARGN})
- add_library("${name}" $<TARGET_OBJECTS:${objlib}>)
- set_property(TARGET "${name}"
- PROPERTY
- FOLDER "libs")
+ set(objlib obj_${MONERO_ADD_LIBRARY_NAME})
+ add_library(${objlib} OBJECT ${MONERO_ADD_LIBRARY_SOURCES})
+ add_library("${MONERO_ADD_LIBRARY_NAME}" $<TARGET_OBJECTS:${objlib}>)
+ if (MONERO_ADD_LIBRARY_DEPENDS)
+ add_dependencies(${objlib} ${MONERO_ADD_LIBRARY_DEPENDS})
+ endif()
+ set_property(TARGET "${MONERO_ADD_LIBRARY_NAME}" PROPERTY FOLDER "libs")
target_compile_definitions(${objlib}
- PRIVATE $<TARGET_PROPERTY:${name},INTERFACE_COMPILE_DEFINITIONS>)
+ PRIVATE $<TARGET_PROPERTY:${MONERO_ADD_LIBRARY_NAME},INTERFACE_COMPILE_DEFINITIONS>)
endfunction ()
-set_source_files_properties(${CMAKE_BINARY_DIR}/version.cpp PROPERTIES GENERATED ON)
-monero_add_library(version ${CMAKE_BINARY_DIR}/version.cpp)
+include(Version)
+monero_add_library(version SOURCES ${CMAKE_BINARY_DIR}/version.cpp DEPENDS genversion)
add_subdirectory(common)
add_subdirectory(crypto)
diff --git a/src/version.cmake b/src/version.cmake
deleted file mode 100644
index 45a97cd20..000000000
--- a/src/version.cmake
+++ /dev/null
@@ -1,63 +0,0 @@
-# Copyright (c) 2014-2017, The Monero Project
-#
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without modification, are
-# permitted provided that the following conditions are met:
-#
-# 1. Redistributions of source code must retain the above copyright notice, this list of
-# conditions and the following disclaimer.
-#
-# 2. Redistributions in binary form must reproduce the above copyright notice, this list
-# of conditions and the following disclaimer in the documentation and/or other
-# materials provided with the distribution.
-#
-# 3. Neither the name of the copyright holder nor the names of its contributors may be
-# used to endorse or promote products derived from this software without specific
-# prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
-# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
-# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
-# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-# Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
-
-# Check what commit we're on
-execute_process(COMMAND "${GIT}" rev-parse --short HEAD RESULT_VARIABLE RET OUTPUT_VARIABLE COMMIT OUTPUT_STRIP_TRAILING_WHITESPACE)
-
-if(RET)
- # Something went wrong, set the version tag to -unknown
-
- message(WARNING "Cannot determine current commit. Make sure that you are building either from a Git working tree or from a source archive.")
- set(VERSIONTAG "unknown")
- configure_file("src/version.cpp.in" "${TO}")
-else()
- message(STATUS "You are currently on commit ${COMMIT}")
-
- # Get all the tags
- execute_process(COMMAND "${GIT}" rev-list --tags --max-count=1 --abbrev-commit RESULT_VARIABLE RET OUTPUT_VARIABLE TAGGEDCOMMIT OUTPUT_STRIP_TRAILING_WHITESPACE)
-
- if(NOT TAGGEDCOMMIT)
- message(WARNING "Cannot determine most recent tag. Make sure that you are building either from a Git working tree or from a source archive.")
- set(VERSIONTAG "${COMMIT}")
- else()
- message(STATUS "The most recent tag was at ${TAGGEDCOMMIT}")
-
- # Check if we're building that tagged commit or a different one
- if(COMMIT STREQUAL TAGGEDCOMMIT)
- message(STATUS "You are building a tagged release")
- set(VERSIONTAG "release")
- else()
- message(STATUS "You are ahead of or behind a tagged release")
- set(VERSIONTAG "${COMMIT}")
- endif()
- endif()
-
- configure_file("src/version.cpp.in" "${TO}")
-endif()