From 42a644c0efcca234376ab8d9f645f137d1e24727 Mon Sep 17 00:00:00 2001 From: Richard Roberts Date: Mon, 30 Nov 2009 23:20:07 +0000 Subject: [PATCH] A few bug fixes --- buildtools/cmake_wrapper.mk | 9 ++++++- buildtools/gt.cmake | 49 +++++++++++++++++++++++++++++-------- 2 files changed, 47 insertions(+), 11 deletions(-) diff --git a/buildtools/cmake_wrapper.mk b/buildtools/cmake_wrapper.mk index 92a0a15c2..17e00892d 100644 --- a/buildtools/cmake_wrapper.mk +++ b/buildtools/cmake_wrapper.mk @@ -36,7 +36,8 @@ configure: cmake ; cmake ccmake cmake_gui: builddir_exists cd ${BUILD}; $@ ${CMAKE_OPTIONS} .. -# Re-run CMake if the Makefile is out of date or non-existant +# Re-run CMake if the Makefile is non-existant. The CMake-generated makefile +# will run CMake if the Makefile is out-of-date. ${BUILD}/Makefile: @if [ ! -d ${BUILD} ]; then \ echo "[cmake_wrapper]: mkdir ${BUILD}"; \ @@ -68,6 +69,12 @@ builddir_exists: mkdir ${BUILD}; \ fi +# Hack to make sure "make install" does something when there is an INSTALL file +.PHONY: install +install: + make -f$(lastword ${MAKEFILE_LIST}) ${BUILD}/Makefile + VERBOSE=1 make -C${BUILD} $@ + # Default rule to pass target to CMake Makefile %: make -f$(lastword ${MAKEFILE_LIST}) ${BUILD}/Makefile diff --git a/buildtools/gt.cmake b/buildtools/gt.cmake index 790215066..ed25c8bb9 100644 --- a/buildtools/gt.cmake +++ b/buildtools/gt.cmake @@ -78,6 +78,14 @@ endfunction(GT_EXCLUDE) # Define "common" sources when there is no main library or executable function(GT_MAIN_SOURCES) + gt_main_sources_helper(${ARGN}) + set(GT_COMMON_SOURCES "${GT_COMMON_SOURCES}" PARENT_SCOPE) + # Build a "convenience" static library + add_library(${PROJECT_NAME}-static STATIC ${GT_COMMON_SOURCES}) + SET_TARGET_PROPERTIES(${PROJECT_NAME}-static PROPERTIES OUTPUT_NAME "${PROJECT_NAME}") + SET_TARGET_PROPERTIES(${PROJECT_NAME}-static PROPERTIES CLEAN_DIRECT_OUTPUT 1) +endfunction(GT_MAIN_SOURCES) +function(GT_MAIN_SOURCES_HELPER) set(GT_COMMON_SOURCES "") foreach(srcpat ${ARGN}) # Get the sources matching the specified pattern @@ -85,9 +93,11 @@ function(GT_MAIN_SOURCES) set(GT_COMMON_SOURCES ${GT_COMMON_SOURCES} ${srcs}) #message(STATUS "Adding sources: " ${srcs}) endforeach(srcpat) - list(REMOVE_ITEM GT_COMMON_SOURCES ${GT_EXCLUDE_SOURCES}) + if(GT_EXCLUDE_SOURCES) + list(REMOVE_ITEM GT_COMMON_SOURCES ${GT_EXCLUDE_SOURCES}) + endif(GT_EXCLUDE_SOURCES) set(GT_COMMON_SOURCES "${GT_COMMON_SOURCES}" PARENT_SCOPE) -endfunction(GT_MAIN_SOURCES) +endfunction(GT_MAIN_SOURCES_HELPER) # Add headers to be installed function(GT_INSTALL_HEADERS) @@ -104,10 +114,10 @@ function(GT_MAIN_LIB) set(GT_COMMON_SOURCES "${GT_COMMON_SOURCES}" PARENT_SCOPE) message(STATUS "[gt.cmake] Adding main lib \"${PROJECT_NAME}\" with sources ${GT_COMMON_SOURCES}") add_library(${PROJECT_NAME} SHARED ${GT_COMMON_SOURCES}) - add_library(${PROJECT_NAME}-static STATIC ${GT_COMMON_SOURCES}) - SET_TARGET_PROPERTIES(${PROJECT_NAME}-static PROPERTIES OUTPUT_NAME "${PROJECT_NAME}") + #add_library(${PROJECT_NAME}-static STATIC ${GT_COMMON_SOURCES}) + #SET_TARGET_PROPERTIES(${PROJECT_NAME}-static PROPERTIES OUTPUT_NAME "${PROJECT_NAME}") SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES CLEAN_DIRECT_OUTPUT 1) - SET_TARGET_PROPERTIES(${PROJECT_NAME}-static PROPERTIES CLEAN_DIRECT_OUTPUT 1) + #SET_TARGET_PROPERTIES(${PROJECT_NAME}-static PROPERTIES CLEAN_DIRECT_OUTPUT 1) install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}-static LIBRARY DESTINATION "lib" ARCHIVE DESTINATION "lib") endfunction(GT_MAIN_LIB) @@ -116,10 +126,20 @@ function(GT_MAIN_STLIB) gt_main_sources(${ARGN}) set(GT_COMMON_SOURCES "${GT_COMMON_SOURCES}" PARENT_SCOPE) message(STATUS "[gt.cmake] Adding main stlib \"${PROJECT_NAME}\" with sources ${GT_COMMON_SOURCES}") - add_library(${PROJECT_NAME} STATIC ${GT_COMMON_SOURCES}) - install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION "lib") + #add_library(${PROJECT_NAME} STATIC ${GT_COMMON_SOURCES}) + install(TARGETS ${PROJECT_NAME}-static ARCHIVE DESTINATION "lib") endfunction(GT_MAIN_STLIB) +# Set the build version for the main library +function(GT_MAIN_VERSION version) + set_target_properties(${PROJECT_NAME} PROPERTIES VERSION "${version}") +endfunction(GT_MAIN_VERSION) + +# Set the API version for the main library +function(GT_MAIN_SOVERSION soversion) + set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION "${soversion}") +endfunction(GT_MAIN_SOVERSION) + # Define the main executable from the given sources #function(GT_MAIN_EXE) # gt_main_sources(${ARGN}) @@ -141,7 +161,10 @@ function(GT_AUTO_EXES) foreach(src ${srcs}) gt_get_stem(exe ${src}) message(STATUS "[gt.cmake] Adding auto exe \"${exe}\" from ${src}") - add_executable(${exe} ${src} ${GT_COMMON_SOURCES}) + add_executable(${exe} ${src}) + if(TARGET ${PROJECT_NAME}-static) + target_link_libraries(${exe} ${PROJECT_NAME}-static) + endif(TARGET ${PROJECT_NAME}-static) endforeach(src ${srcs}) endforeach(srcpat ${ARGN}) endfunction(GT_AUTO_EXES) @@ -154,7 +177,10 @@ function(GT_AUTO_INSTALLED_EXES) foreach(src ${srcs}) gt_get_stem(exe ${src}) message(STATUS "[gt.cmake] Adding auto installed exe \"${exe}\" from ${src}") - add_executable(${exe} ${src} ${GT_COMMON_SOURCES}) + add_executable(${exe} ${src}) + if(TARGET ${PROJECT_NAME}-static) + target_link_libraries(${exe} ${PROJECT_NAME}-static) + endif(TARGET ${PROJECT_NAME}-static) install(TARGETS ${exe} RUNTIME DESTINATION "bin") endforeach(src ${srcs}) endforeach(srcpat ${ARGN}) @@ -177,8 +203,11 @@ function(GT_AUTO_TESTS) foreach(src ${srcs}) gt_get_stem(exe ${src}) message(STATUS "[gt.cmake] Adding test \"${exe}\" from ${src}") - add_executable(${exe} ${src} ${GT_COMMON_SOURCES}) + add_executable(${exe} ${src}) target_link_libraries(${exe} "CppUnitLite") + if(TARGET ${PROJECT_NAME}-static) + target_link_libraries(${exe} ${PROJECT_NAME}-static) + endif(TARGET ${PROJECT_NAME}-static) add_test(${exe} ${exe}) endforeach(src ${srcs}) endforeach(srcpat ${ARGN})