Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Eyescale/CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Eilemann authored and Stefan Eilemann committed Mar 4, 2014
2 parents 8386a0b + 6516537 commit 73457cc
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 45 deletions.
10 changes: 5 additions & 5 deletions Buildyard.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ endif()

message(STATUS "Bootstrap Buildyard for missing${FIND_REQUIRED_FAILED}")
include(GitExternal)
include(UpdateFile)

git_external("${CMAKE_BINARY_DIR}/Buildyard"
https://github.com/Eyescale/Buildyard.git master)

update_file("${CMAKE_SOURCE_DIR}/CMake/${CMAKE_PROJECT_NAME}.cmake"
"${CMAKE_BINARY_DIR}/Buildyard/config.Buildyard/${CMAKE_PROJECT_NAME}.cmake")
update_file("${CMAKE_SOURCE_DIR}/CMake/depends.txt"
"${CMAKE_BINARY_DIR}/Buildyard/config.Buildyard/depends.txt")
configure_file("${CMAKE_SOURCE_DIR}/CMake/${CMAKE_PROJECT_NAME}.cmake"
"${CMAKE_BINARY_DIR}/Buildyard/config.Buildyard/${CMAKE_PROJECT_NAME}.cmake"
COPYONLY)
configure_file("${CMAKE_SOURCE_DIR}/CMake/depends.txt"
"${CMAKE_BINARY_DIR}/Buildyard/config.Buildyard/depends.txt" COPYONLY)

set(BUILDYARD_TARGETS ${CMAKE_PROJECT_NAME})
add_subdirectory("${CMAKE_BINARY_DIR}/Buildyard" # source
Expand Down
5 changes: 3 additions & 2 deletions CommonApplication.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
# Configures the build for a simple application:
# common_application(<Name>)
#
# Uses:
# Input:
# * NAME_SOURCES for all compilation units
# * NAME_HEADERS for all internal header files
# * NAME_LINK_LIBRARIES for dependencies of name
# * ARGN for optional add_executable parameters
#
# Builds Name application and installs it.

Expand All @@ -19,7 +20,7 @@ function(COMMON_APPLICATION Name)
set(HEADERS ${${NAME}_HEADERS})
set(LINK_LIBRARIES ${${NAME}_LINK_LIBRARIES})

add_executable(${Name} ${HEADERS} ${SOURCES})
add_executable(${Name} ${ARGN} ${HEADERS} ${SOURCES})
target_link_libraries(${Name} ${LINK_LIBRARIES})
install(TARGETS ${Name} DESTINATION bin COMPONENT apps)
endfunction()
17 changes: 8 additions & 9 deletions CommonCode.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Common.cmake include and cpp files and setting, do not use directly

include(GitInfo)
include(UpdateFile)

set(OUTPUT_INCLUDE_DIR ${CMAKE_BINARY_DIR}/include)
file(MAKE_DIRECTORY ${OUTPUT_INCLUDE_DIR})
Expand All @@ -14,14 +13,14 @@ if(NOT PROJECT_namespace)
endif()
string(TOUPPER ${PROJECT_namespace} PROJECT_NAMESPACE)

update_file(${CMAKE_CURRENT_LIST_DIR}/cpp/api.h
${CMAKE_BINARY_DIR}/include/${PROJECT_INCLUDE_NAME}/api.h)
update_file(${CMAKE_CURRENT_LIST_DIR}/cpp/defines.h
${CMAKE_BINARY_DIR}/include/${PROJECT_INCLUDE_NAME}/defines.h)
update_file(${CMAKE_CURRENT_LIST_DIR}/cpp/version.h
${CMAKE_BINARY_DIR}/include/${PROJECT_INCLUDE_NAME}/version.h)
update_file(${CMAKE_CURRENT_LIST_DIR}/cpp/version.cpp
${CMAKE_CURRENT_BINARY_DIR}/version.cpp)
configure_file(${CMAKE_CURRENT_LIST_DIR}/cpp/api.h
${CMAKE_BINARY_DIR}/include/${PROJECT_INCLUDE_NAME}/api.h @ONLY)
configure_file(${CMAKE_CURRENT_LIST_DIR}/cpp/defines.h
${CMAKE_BINARY_DIR}/include/${PROJECT_INCLUDE_NAME}/defines.h @ONLY)
configure_file(${CMAKE_CURRENT_LIST_DIR}/cpp/version.h
${CMAKE_BINARY_DIR}/include/${PROJECT_INCLUDE_NAME}/version.h @ONLY)
configure_file(${CMAKE_CURRENT_LIST_DIR}/cpp/version.cpp
${CMAKE_CURRENT_BINARY_DIR}/version.cpp @ONLY)

list(APPEND COMMON_INCLUDES
${CMAKE_BINARY_DIR}/include/${PROJECT_INCLUDE_NAME}/api.h
Expand Down
5 changes: 2 additions & 3 deletions CommonLibrary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# headers.

include(InstallFiles)
include(UpdateFile)

function(COMMON_LIBRARY Name)
string(TOUPPER ${Name} NAME)
Expand Down Expand Up @@ -44,8 +43,8 @@ function(COMMON_LIBRARY Name)
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/${name}.in.h "#endif\n")
set(PROJECT_INCLUDE_HEADER ${CMAKE_BINARY_DIR}/include/${PROJECT_INCLUDE_NAME}/${PROJECT_INCLUDE_NAME}.h)

update_file(${CMAKE_CURRENT_BINARY_DIR}/${name}.in.h
${PROJECT_INCLUDE_HEADER})
configure_file(${CMAKE_CURRENT_BINARY_DIR}/${name}.in.h
${PROJECT_INCLUDE_HEADER} COPYONLY)
list(APPEND PUBLIC_HEADERS ${PROJECT_INCLUDE_HEADER})

if(SOURCES)
Expand Down
5 changes: 2 additions & 3 deletions Doxygit.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ find_package(Git)
if(NOT GIT_EXECUTABLE)
return()
endif()
include(UpdateFile)

file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/index.html"
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd\">\n"
Expand Down Expand Up @@ -105,8 +104,8 @@ file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/index.html"
"</html>\n"
)

update_file("${CMAKE_CURRENT_BINARY_DIR}/index.html"
"${CMAKE_SOURCE_DIR}/index.html")
configure_file("${CMAKE_CURRENT_BINARY_DIR}/index.html"
"${CMAKE_SOURCE_DIR}/index.html" COPYONLY)

execute_process(COMMAND "${GIT_EXECUTABLE}" add images ${ENTRIES}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
Expand Down
23 changes: 23 additions & 0 deletions FindOpenMesh.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (c) 2014 Stefan.Eilemann@epfl.ch

find_path(_openMesh_INCLUDE_DIR OpenMesh/Core/Geometry/Config.hh
HINTS ${OPENMESH_ROOT}/include
PATHS /usr/include /usr/local/include /opt/local/include)

find_library(_openMesh_CORE_LIBRARY NAMES openMeshCore openMeshCored
HINTS ${OPENMESH_ROOT}/lib/OpenMesh
PATHS /usr/lib/OpenMesh /usr/local/lib/OpenMesh /opt/local/lib/OpenMesh)

find_library(_openMesh_TOOLS_LIBRARY NAMES openMeshTools openMeshToolsd
HINTS ${OPENMESH_ROOT}/lib/OpenMesh
PATHS /usr/lib/OpenMesh /usr/local/lib/OpenMesh /opt/local/lib/OpenMesh)

include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OPENMESH DEFAULT_MSG
_openMesh_INCLUDE_DIR _openMesh_CORE_LIBRARY _openMesh_TOOLS_LIBRARY)

set(OPENMESH_INCLUDE_DIRS ${_openMesh_INCLUDE_DIR})
set(OPENMESH_LIBRARIES ${_openMesh_CORE_LIBRARY} ${_openMesh_TOOLS_LIBRARY})
if(OPENMESH_FOUND AND NOT OPENMESH_FIND_QUIETLY)
message(STATUS "Found OpenMesh in ${OPENMESH_INCLUDE_DIRS};${OPENMESH_LIBRARIES}")
endif()
8 changes: 3 additions & 5 deletions FindVTune.cmake
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@

# Copyright (c) 2013 Stefan.Eilemann@epfl.ch
# Copyright (c) 2013-2014 Stefan.Eilemann@epfl.ch
# finds the ittnotify API
# if not found, installs a dummy ittnotify.h to build_dir/include to eliminate
# the need to protect the itt calls with ifdefs

include(UpdateFile)

if(CMAKE_VERSION VERSION_LESS 2.8.3) # WAR bug
get_filename_component(CMAKE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
endif()
Expand All @@ -20,8 +18,8 @@ endif()
find_program(VTUNE_EXECUTABLE amplxe-cl)
if(NOT VTUNE_EXECUTABLE)
set(VTUNE_FOUND)
update_file(${CMAKE_CURRENT_LIST_DIR}/ittnotify.h
${CMAKE_BINARY_DIR}/include/ittnotify.h)
configure_file(${CMAKE_CURRENT_LIST_DIR}/ittnotify.h
${CMAKE_BINARY_DIR}/include/ittnotify.h COPYONLY)
add_definitions(-DINTEL_NO_ITTNOTIFY_API)
return()
endif()
Expand Down
21 changes: 14 additions & 7 deletions GitExternal.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ if(NOT GIT_EXECUTABLE)
endif()

include(CMakeParseArguments)
include(CommonProcess)

function(GIT_EXTERNAL DIR REPO TAG)
cmake_parse_arguments(GIT_EXTERNAL "" "" "RESET" ${ARGN})
Expand All @@ -25,34 +24,42 @@ function(GIT_EXTERNAL DIR REPO TAG)

if(NOT EXISTS "${DIR}")
message(STATUS "git clone ${REPO} ${DIR}")
common_process("git clone ${DIR}" FATAL_ERROR
execute_process(
COMMAND "${GIT_EXECUTABLE}" clone "${REPO}" "${DIR}"
RESULT_VARIABLE nok ERROR_VARIABLE error
WORKING_DIRECTORY "${GIT_EXTERNAL_DIR}")
if(nok)
message(FATAL_ERROR "${DIR} git clone failed: ${error}\n")
endif()
endif()

if(IS_DIRECTORY "${DIR}/.git")
foreach(GIT_EXTERNAL_RESET_FILE ${GIT_EXTERNAL_RESET})
common_process("git reset ${GIT_EXTERNAL_RESET_FILE}" STATUS
execute_process(
COMMAND "${GIT_EXECUTABLE}" reset -q "${GIT_EXTERNAL_RESET_FILE}"
RESULT_VARIABLE nok ERROR_VARIABLE error
WORKING_DIRECTORY "${DIR}")
common_process("git checkout -- ${GIT_EXTERNAL_RESET_FILE}" STATUS
execute_process(
COMMAND "${GIT_EXECUTABLE}" checkout -q -- "${GIT_EXTERNAL_RESET_FILE}"
RESULT_VARIABLE nok ERROR_VARIABLE error
WORKING_DIRECTORY "${DIR}")
endforeach()

common_process("Update {$DIR}" STATUS
COMMAND "${GIT_EXECUTABLE}" fetch --all -q
execute_process(COMMAND "${GIT_EXECUTABLE}" fetch --all -q
RESULT_VARIABLE nok ERROR_VARIABLE error
WORKING_DIRECTORY "${DIR}")
if(nok)
message(STATUS "Update of ${DIR} failed:\n ${error}")
endif()

common_process("${DIR} git checkout ${TAG}" STATUS
execute_process(
COMMAND "${GIT_EXECUTABLE}" checkout -q "${TAG}"
RESULT_VARIABLE nok ERROR_VARIABLE error
WORKING_DIRECTORY "${DIR}"
)
if(nok)
message(STATUS "${DIR} git checkout ${TAG} failed: ${error}\n")
endif()
else()
message(STATUS "Can't update git external ${DIR}: Not a git repository")
endif()
Expand Down
6 changes: 2 additions & 4 deletions MacPorts.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ if(NOT CPACK_MACPORTS_CATEGORY)
return()
endif()

include(UpdateFile)
include(GithubOrganization)

# Configurables
Expand Down Expand Up @@ -42,16 +41,15 @@ set(PORTFILE_GH_DIR "${CMAKE_SOURCE_DIR}/../${MACPORTS_DIR}")
set(PORTFILE "${CMAKE_BINARY_DIR}/${PORTFILE_DIR}/Portfile")
set(PORTFILE_GH "${PORTFILE_GH_DIR}/${PORTFILE_DIR}/Portfile")

update_file(${CMAKE_SOURCE_DIR}/CMake/Portfile ${PORTFILE})
configure_file(${CMAKE_SOURCE_DIR}/CMake/Portfile ${PORTFILE} @ONLY)
install(FILES ${PORTFILE} DESTINATION ${PORTFILE_DIR} COMPONENT lib)
install(CODE
"execute_process(COMMAND /opt/local/bin/portindex ${CMAKE_INSTALL_PREFIX}/ports)"
COMPONENT lib)

file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/MacPortfile.cmake
"list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake)\n"
"include(UpdateFile)\n"
"update_file(${PORTFILE} ${PORTFILE_GH})\n"
"configure_file(${PORTFILE} ${PORTFILE_GH} COPYONLY)\n"
"execute_process(COMMAND /opt/local/bin/portindex ${PORTFILE_GH_DIR}/ports)"
)

Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ origin/master version.
create [GNU modules](http://modules.sourceforge.net/).
* [GitTargets](GitTargets.cmake) *branch*, *cut*, *tag*, *erase*,
*retag*, *tarball* targets.
* [UpdateFile]: *update_file* function using configure_file
but leaves an unchanged target untouched. Uses @ONLY.
* [Compiler](Compiler.cmake): Default compiler flags, useful default
warnings and 'safe' C++11 features.
* [GitInfo](GitInfo.cmake) sets variables with information about the
Expand Down
7 changes: 5 additions & 2 deletions UpdateFile.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@

# Copyright (c) 2012 Stefan Eilemann <eile@eyescale.ch>
# Copyright (c) 2012-2014 Stefan Eilemann <eile@eyescale.ch>

# Similar to configure_file, but overwrites target only if content differs.
# Deprecated since configure_file in fact does the same.

# similar to configure_file, but overwrites target only if content differs
function(UPDATE_FILE IN OUT)
message(WARNING "Update_file is deprecated, use configure_file(... @ONLY)")
if(NOT EXISTS ${OUT})
configure_file(${IN} ${OUT} @ONLY)
return()
Expand Down
5 changes: 2 additions & 3 deletions UpdateGitExternal.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/GitExternal.cmake" AND
EXISTS "${CMAKE_CURRENT_LIST_DIR}/../GitExternal.cmake")

include(UpdateFile)
update_file("${CMAKE_CURRENT_LIST_DIR}/GitExternal.cmake"
"${CMAKE_CURRENT_LIST_DIR}/../GitExternal.cmake")
configure_file("${CMAKE_CURRENT_LIST_DIR}/GitExternal.cmake"
"${CMAKE_CURRENT_LIST_DIR}/../GitExternal.cmake" COPYONLY)
endif()

0 comments on commit 73457cc

Please sign in to comment.