From c5eba4a98b8726524d5e7f47d64ca262e7e4a67f Mon Sep 17 00:00:00 2001 From: kai Date: Mon, 18 Jun 2012 19:50:11 +0200 Subject: [PATCH 1/5] New CMake module to locate libconfig++ The current code to locate libconfig++ has some trouble: - It is located in the main CMakeList file but should be a module of its own - It depends on pkg-config which is not available on Windows - The returned values are not really useful therefore the library name is hard coded This commit tries to solve these problems. For a Unix-like system there should be no difference. Additionally, you can override the variables on the command line which is useful for builds on Windows. --- CMakeLists.txt | 23 +++-------------------- cmake/Modules/FindLibConfig++.cmake | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 20 deletions(-) create mode 100644 cmake/Modules/FindLibConfig++.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 228253c9..b0788e2a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,25 +23,7 @@ find_package(LLVM 3.0 EXACT REQUIRED # # Locate libconfig++. # - -include(FindPkgConfig) -if(PKG_CONFIG_FOUND) - pkg_search_module(LIBCONFIGPP libconfig++) - if(LIBCONFIGPP_FOUND) - set(LIBCONFIG_CXXFLAGS ${LIBCONFIGPP_CFLAGS} CACHE STRING "libconfig++ compiler flags") - set(LIBCONFIG_LDFLAGS ${LIBCONFIGPP_LDFLAGS} CACHE STRING "libconfig++ linker flags") - endif() -else() - message(WARNING "pkg-config not found. libconfig++ options cannot be detected, you might need to set them manually.") -endif() - -# libconfig++ is actually a required dependency, but has never been defined as -# one – maybe there was a problem with the auto detection once. -if (NOT LIBCONFIGPP_FOUND) - set(LIBCONFIG_CXXFLAGS "" CACHE STRING "libconfig++ compiler flags") - set(LIBCONFIG_LDFLAGS "" CACHE STRING "libconfig++ linker flags") - message(WARNING "libconfig++ not found. If compilation fails but the library is installed, consider manually setting the LIBCONFIG_CXXFLAGS and LIBCONFIG_LDFLAGS CMake variables.") -endif() +find_package(LibConfig++ REQUIRED) # # Main configuration. @@ -277,6 +259,7 @@ include_directories( ${PROJECT_BINARY_DIR}/${DMDFE_PATH} ${PROJECT_SOURCE_DIR} ${LLVM_INCLUDE_DIRS} + ${LIBCONFIG++_INCLUDE_DIR} ) if(MSVC) @@ -353,7 +336,7 @@ set_target_properties( RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin COMPILE_FLAGS "${LLVM_CXXFLAGS} ${LIBCONFIG_CXXFLAGS} ${EXTRA_CXXFLAGS}" ) -target_link_libraries(${LDC_EXE} ${LDC_LIB} ${LIBCONFIG_LDFLAGS} config++) +target_link_libraries(${LDC_EXE} ${LDC_LIB} ${LIBCONFIG_LDFLAGS} ${LIBCONFIG++_LIBRARY}) # For use by the druntime/Phobos build system. get_target_property(LDC_LOC ${LDC_EXE} LOCATION) diff --git a/cmake/Modules/FindLibConfig++.cmake b/cmake/Modules/FindLibConfig++.cmake new file mode 100644 index 00000000..b63d1ea1 --- /dev/null +++ b/cmake/Modules/FindLibConfig++.cmake @@ -0,0 +1,24 @@ +# Find the libconfig++ includes and library +# +# This module defines +# LIBCONFIG++_INCLUDE_DIR, where to find libconfig++ include files, etc. +# LIBCONFIG++_LIBRARy, the library to link against to use libconfig++. +# LIBCONFIG++_FOUND, If false, do not try to use libconfig++. + +# also defined, but not for general use are +# LIBCONFIG++_LIBRARY, where to find the libconfig++ library. + +set(LIBCONFIG++_FOUND TRUE) + +find_path(LIBCONFIG++_INCLUDE_DIR libconfig.h++) + +find_library(LIBCONFIG++_LIBRARY config++) + +if (LIBCONFIG++_INCLUDE_DIR AND LIBCONFIG++_LIBRARY) + set(LIBCONFIG++_FOUND TRUE) +endif (LIBCONFIG++_INCLUDE_DIR AND LIBCONFIG++_LIBRARY) + +# Use the default CMake facilities for handling QUIET/REQUIRED. +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(LLVM + REQUIRED_VARS LIBCONFIG++_INCLUDE_DIR LIBCONFIG++_LIBRARY) From 6dd643608a0da52b3f66cada57607524bca151bb Mon Sep 17 00:00:00 2001 From: kai Date: Mon, 18 Jun 2012 21:26:18 +0200 Subject: [PATCH 2/5] Fix for review comments. --- cmake/Modules/FindLibConfig++.cmake | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cmake/Modules/FindLibConfig++.cmake b/cmake/Modules/FindLibConfig++.cmake index b63d1ea1..6b6a78e0 100644 --- a/cmake/Modules/FindLibConfig++.cmake +++ b/cmake/Modules/FindLibConfig++.cmake @@ -2,12 +2,9 @@ # # This module defines # LIBCONFIG++_INCLUDE_DIR, where to find libconfig++ include files, etc. -# LIBCONFIG++_LIBRARy, the library to link against to use libconfig++. +# LIBCONFIG++_LIBRARY, the library to link against to use libconfig++. # LIBCONFIG++_FOUND, If false, do not try to use libconfig++. -# also defined, but not for general use are -# LIBCONFIG++_LIBRARY, where to find the libconfig++ library. - set(LIBCONFIG++_FOUND TRUE) find_path(LIBCONFIG++_INCLUDE_DIR libconfig.h++) From 51256b8c8205086b459cb9dc0ceab65b5869bf7b Mon Sep 17 00:00:00 2001 From: kai Date: Tue, 19 Jun 2012 06:44:36 +0200 Subject: [PATCH 3/5] Fixed a wrong variable reference. --- cmake/Modules/FindLibConfig++.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/Modules/FindLibConfig++.cmake b/cmake/Modules/FindLibConfig++.cmake index 6b6a78e0..e218609a 100644 --- a/cmake/Modules/FindLibConfig++.cmake +++ b/cmake/Modules/FindLibConfig++.cmake @@ -17,5 +17,5 @@ endif (LIBCONFIG++_INCLUDE_DIR AND LIBCONFIG++_LIBRARY) # Use the default CMake facilities for handling QUIET/REQUIRED. include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(LLVM +find_package_handle_standard_args(LIBCONFIG++ REQUIRED_VARS LIBCONFIG++_INCLUDE_DIR LIBCONFIG++_LIBRARY) From eb008fac44e8fc57706d5d55f0528092aa54ab11 Mon Sep 17 00:00:00 2001 From: kai Date: Tue, 19 Jun 2012 06:52:46 +0200 Subject: [PATCH 4/5] Fixed wrong default value for LIBCONFIG++_FOUND --- cmake/Modules/FindLibConfig++.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/Modules/FindLibConfig++.cmake b/cmake/Modules/FindLibConfig++.cmake index e218609a..28c9712e 100644 --- a/cmake/Modules/FindLibConfig++.cmake +++ b/cmake/Modules/FindLibConfig++.cmake @@ -5,7 +5,7 @@ # LIBCONFIG++_LIBRARY, the library to link against to use libconfig++. # LIBCONFIG++_FOUND, If false, do not try to use libconfig++. -set(LIBCONFIG++_FOUND TRUE) +set(LIBCONFIG++_FOUND FALSE) find_path(LIBCONFIG++_INCLUDE_DIR libconfig.h++) From 79c02f2a793755a9b8c259ce30caa586ac281ba6 Mon Sep 17 00:00:00 2001 From: kai Date: Tue, 19 Jun 2012 18:08:42 +0200 Subject: [PATCH 5/5] Remove some old variables which are unused now. --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b0788e2a..a5f15a91 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -313,7 +313,7 @@ set_target_properties( ARCHIVE_OUTPUT_NAME ldc LIBRARY_OUTPUT_NAME ldc RUNTIME_OUTPUT_NAME ldc - COMPILE_FLAGS "${LLVM_CXXFLAGS} ${LIBCONFIG_CXXFLAGS} ${EXTRA_CXXFLAGS}" + COMPILE_FLAGS "${LLVM_CXXFLAGS} ${EXTRA_CXXFLAGS}" ) # LDFLAGS should actually be in target property LINK_FLAGS, but this works, and gets around linking problems @@ -334,9 +334,9 @@ set_target_properties( ${LDC_EXE} PROPERTIES OUTPUT_NAME ${LDC_EXE_NAME} RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin - COMPILE_FLAGS "${LLVM_CXXFLAGS} ${LIBCONFIG_CXXFLAGS} ${EXTRA_CXXFLAGS}" + COMPILE_FLAGS "${LLVM_CXXFLAGS} ${EXTRA_CXXFLAGS}" ) -target_link_libraries(${LDC_EXE} ${LDC_LIB} ${LIBCONFIG_LDFLAGS} ${LIBCONFIG++_LIBRARY}) +target_link_libraries(${LDC_EXE} ${LDC_LIB} ${LIBCONFIG++_LIBRARY}) # For use by the druntime/Phobos build system. get_target_property(LDC_LOC ${LDC_EXE} LOCATION)