From e8359d300c53b233adc638da87d5b56a91c6d9ae Mon Sep 17 00:00:00 2001 From: Gennady Pospelov <g.pospelov@fz-juelich.de> Date: Tue, 17 Sep 2013 15:08:36 +0200 Subject: [PATCH] libManhattan added to cmake project, lots of code cleanup in cmake --- App/CMakeLists.txt | 19 +++-- CMakeLists.txt | 2 +- Core/CMakeLists.txt | 49 ++++++----- Fit/CMakeLists.txt | 36 +++++--- .../qt-manhattan-style/FancyTabWidget.sip | 22 ----- .../qt-manhattan-style/ManhattanStyle.sip | 8 -- Tests/UnitTests/TestCore/CMakeLists.txt | 14 ++-- ThirdParty/RootMinimizers/CMakeLists.txt | 24 ++---- cmake/modules/SearchInstalledSoftware.cmake | 84 ++++++++----------- 9 files changed, 110 insertions(+), 148 deletions(-) delete mode 100644 GUI/externals/qt-manhattan-style/FancyTabWidget.sip delete mode 100644 GUI/externals/qt-manhattan-style/ManhattanStyle.sip diff --git a/App/CMakeLists.txt b/App/CMakeLists.txt index 33481dff90d..071c3b3bd72 100644 --- a/App/CMakeLists.txt +++ b/App/CMakeLists.txt @@ -55,12 +55,19 @@ ROOT_GENERATE_DICTIONARY(AppDict inc/DrawHelper.h inc/TreeEventStructure.h L add_executable(${executable_name} ${source_files} AppDict.cxx ${header_files}) # --- dependencies --- -include_directories(${BornAgainCore_INCLUDE_DIRS}) -target_link_libraries(${executable_name} ${BornAgainCore_LIBRARY}) -include_directories(${BornAgainFit_INCLUDE_DIRS}) -target_link_libraries(${executable_name} ${BornAgainFit_LIBRARY}) -include_directories(${ROOT_INCLUDE_DIR}) -target_link_libraries(${executable_name} ${ROOT_LIBRARIES}) +include_directories( + ${Boost_INCLUDE_DIRS} + ${BornAgainCore_INCLUDE_DIRS} + ${BornAgainFit_INCLUDE_DIRS} + ${EIGEN3_INCLUDE_DIR} + ${ROOT_INCLUDE_DIR} +) +target_link_libraries(${executable_name} + ${Boost_LIBRARIES} + ${BornAgainCore_LIBRARY} + ${BornAgainFit_LIBRARY} + ${ROOT_LIBRARIES} +) # --- Installation --- install (TARGETS ${executable_name} DESTINATION bin COMPONENT Applications) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5db9b8e8996..ed74303c48e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ if(NOT BORNAGAIN_PYTHON) endif() if(NOT BORNAGAIN_APP) -# set(BORNAGAIN_APP ON) + set(BORNAGAIN_APP ON) endif() if(NOT BORNAGAIN_GUI) diff --git a/Core/CMakeLists.txt b/Core/CMakeLists.txt index a0d1f0a8bc7..d487d332ab9 100644 --- a/Core/CMakeLists.txt +++ b/Core/CMakeLists.txt @@ -3,7 +3,7 @@ ############################################################################ set(library_name BornAgainCore) -# source and include files +# --- source and include files --- set(include_dirs ${CMAKE_CURRENT_SOURCE_DIR}/Algorithms/inc ${CMAKE_CURRENT_SOURCE_DIR}/FormFactors/inc @@ -44,7 +44,7 @@ if(WIN32) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBA_CORE_BUILD_DLL") endif() -# making library +# --- making library --- add_library( ${library_name} SHARED @@ -52,24 +52,29 @@ add_library( ) set_Target_properties(${library_name} PROPERTIES PREFIX ${libprefix} SUFFIX ${libsuffix}) set(${library_name}_LIBRARY_TYPE SHARED) +# exposing library name and list of include directories outside +set(${library_name}_INCLUDE_DIRS ${include_dirs} PARENT_SCOPE) +set(${library_name}_LIBRARY ${library_name} PARENT_SCOPE) -# external dependencies -include_directories(${Boost_INCLUDE_DIRS}) -target_link_libraries(${library_name} ${Boost_LIBRARIES}) -target_link_libraries(${library_name} ${FFTW_LIBRARY}) -target_link_libraries(${library_name} ${GSL_LIBRARIES}) -target_link_libraries(${library_name} ${PYTHON_LIBRARIES}) - -# copying library into lib directory for functional tests -#execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/lib) -#ADD_CUSTOM_COMMAND( -# TARGET ${library_name} -# POST_BUILD -# COMMAND ${CMAKE_COMMAND} -E copy -# ${libprefix}${library_name}${libsuffix} -# ${CMAKE_BINARY_DIR}/lib/ -#) +# --- external dependencies --- +include_directories( + ${EIGEN3_INCLUDE_DIR} + ${Boost_INCLUDE_DIRS} + ${FFTW_INCLUDE_DIR} + ${GSL_INCLUDE_DIR} +) +target_link_libraries( + ${library_name} + ${Boost_LIBRARIES} + ${FFTW_LIBRARY} + ${GSL_LIBRARIES} +) +if(BORNAGAIN_PYTHON) + include_directories(${PYTHON_INCLUDE_DIRS} ${NUMPY_INCLUDE_DIR}) + target_link_libraries(${library_name} ${PYTHON_LIBRARIES}) +endif() +# --- custom actions --- # python in windows required .pyd extention for the library name if(WIN32 AND BORNAGAIN_PYTHON) ADD_CUSTOM_COMMAND( @@ -81,17 +86,13 @@ if(WIN32 AND BORNAGAIN_PYTHON) ) endif() -# exposing library name and list of include directories outside -set(${library_name}_INCLUDE_DIRS ${include_dirs} PARENT_SCOPE) -set(${library_name}_LIBRARY ${library_name} PARENT_SCOPE) - # ----------------------------------------------- # installation +# FIXME sometimes installation goes in two place (lib, bin), this is temporary # ----------------------------------------------- install (DIRECTORY ${CMAKE_SOURCE_DIR}/Examples/ DESTINATION Examples COMPONENT Examples FILES_MATCHING PATTERN "*.py" ) install (DIRECTORY ${CMAKE_SOURCE_DIR}/Examples/ DESTINATION Examples COMPONENT Examples FILES_MATCHING PATTERN "README") install (DIRECTORY ${CMAKE_SOURCE_DIR}/bin/ DESTINATION bin COMPONENT Libraries) - install (TARGETS ${library_name} DESTINATION lib COMPONENT Libraries) install (TARGETS ${library_name} DESTINATION bin COMPONENT Libraries) @@ -103,7 +104,6 @@ if(WIN32 AND BORNAGAIN_PYTHON) install(FILES ${CMAKE_BINARY_DIR}/lib/${libprefix}${library_name}.pyd DESTINATION bin COMPONENT Libraries) - endif() # list of headers to install @@ -140,4 +140,3 @@ if(WIN32) install (FILES ${GSL_LIBRARIES} DESTINATION bin COMPONENT Libraries) endif() endif() - diff --git a/Fit/CMakeLists.txt b/Fit/CMakeLists.txt index ae81bfc8c27..c670187746a 100644 --- a/Fit/CMakeLists.txt +++ b/Fit/CMakeLists.txt @@ -38,17 +38,30 @@ add_library( ) set_Target_properties(${library_name} PROPERTIES PREFIX ${libprefix} SUFFIX ${libsuffix}) set(${library_name}_LIBRARY_TYPE SHARED) +# exposing library name and list of include directories outside +set(${library_name}_INCLUDE_DIRS ${include_dirs} PARENT_SCOPE) +set(${library_name}_LIBRARY ${library_name} PARENT_SCOPE) -# dependencies -include_directories(${BornAgainCore_INCLUDE_DIRS}) -target_link_libraries(${library_name} ${BornAgainCore_LIBRARY}) -target_link_libraries(${library_name} ${GSL_LIBRARIES}) -include_directories(${RootMinimizers_INCLUDE_DIRS}) -target_link_libraries(${library_name} ${RootMinimizers_LIBRARY}) -include_directories(${Boost_INCLUDE_DIRS}) -target_link_libraries(${library_name} ${Boost_LIBRARIES}) +# --- dependencies --- +include_directories( + ${BornAgainCore_INCLUDE_DIRS} + ${Boost_INCLUDE_DIRS} + ${EIGEN3_INCLUDE_DIR} + ${RootMinimizers_INCLUDE_DIRS} +) +target_link_libraries( + ${library_name} + ${BornAgainCore_LIBRARY} + ${Boost_LIBRARIES} + ${RootMinimizers_LIBRARY} +) +if(BORNAGAIN_PYTHON) + include_directories(${PYTHON_INCLUDE_DIRS}) + target_link_libraries(${library_name} ${PYTHON_LIBRARIES}) +endif() -# python in windows required .yd extention for the library name +# --- custom actions +# python in windows required .pyd extention for the library name if(WIN32 AND BORNAGAIN_PYTHON) ADD_CUSTOM_COMMAND( TARGET ${library_name} @@ -59,12 +72,9 @@ if(WIN32 AND BORNAGAIN_PYTHON) ) endif() -# exposing library name and list of include directories outside -set(${library_name}_INCLUDE_DIRS ${include_dirs} PARENT_SCOPE) -set(${library_name}_LIBRARY ${library_name} PARENT_SCOPE) - # ----------------------------------------------- # installation +# FIXME sometimes installation goes in two place (lib, bin), this is temporary # ----------------------------------------------- install (TARGETS ${library_name} DESTINATION lib COMPONENT Libraries) install (TARGETS ${library_name} DESTINATION bin COMPONENT Libraries) diff --git a/GUI/externals/qt-manhattan-style/FancyTabWidget.sip b/GUI/externals/qt-manhattan-style/FancyTabWidget.sip deleted file mode 100644 index eabf9de7866..00000000000 --- a/GUI/externals/qt-manhattan-style/FancyTabWidget.sip +++ /dev/null @@ -1,22 +0,0 @@ - - - -%Import QtGui/QtGuimod.sip - -namespace Manhattan { - -class FancyTabWidget : public QWidget{ - -%TypeHeaderCode -#include "fancytabwidget.h" -%End - -public: - - FancyTabWidget(QWidget *parent = 0); - - void insertTab(int index, QWidget *tab /TransferThis/, const QIcon &icon, const QString &label); - -}; - -}; \ No newline at end of file diff --git a/GUI/externals/qt-manhattan-style/ManhattanStyle.sip b/GUI/externals/qt-manhattan-style/ManhattanStyle.sip deleted file mode 100644 index 3cc63bcdb81..00000000000 --- a/GUI/externals/qt-manhattan-style/ManhattanStyle.sip +++ /dev/null @@ -1,8 +0,0 @@ -%Module ManhattanStyle - -%Import QtGui/QtGuimod.sip -%Import QtCore/QtCoremod.sip -%Import QtWebKit/QtWebKitmod.sip - -%Include FancyTabWidget.sip - diff --git a/Tests/UnitTests/TestCore/CMakeLists.txt b/Tests/UnitTests/TestCore/CMakeLists.txt index 4b04198f1e5..dc5e80f143a 100644 --- a/Tests/UnitTests/TestCore/CMakeLists.txt +++ b/Tests/UnitTests/TestCore/CMakeLists.txt @@ -10,11 +10,15 @@ add_executable( TestCore main.cpp ) include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR}) target_link_libraries(TestCore gtest) -include_directories(${BornAgainCore_INCLUDE_DIRS}) -target_link_libraries(TestCore ${BornAgainCore_LIBRARY}) - -include_directories(${Boost_INCLUDE_DIRS}) -target_link_libraries(TestCore ${Boost_LIBRARIES}) +include_directories( + ${Boost_INCLUDE_DIRS} + ${BornAgainCore_INCLUDE_DIRS} + ${EIGEN3_INCLUDE_DIR} +) +target_link_libraries(TestCore + ${BornAgainCore_LIBRARY} + ${Boost_LIBRARIES} +) # to build executable right in lib directory to not to have problems with finding libBornAgainCore.dll under Windows set_property(TARGET TestCore PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) diff --git a/ThirdParty/RootMinimizers/CMakeLists.txt b/ThirdParty/RootMinimizers/CMakeLists.txt index e04fcebad58..b4271bc55d1 100644 --- a/ThirdParty/RootMinimizers/CMakeLists.txt +++ b/ThirdParty/RootMinimizers/CMakeLists.txt @@ -25,7 +25,7 @@ file(GLOB include_files set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMATH_NO_PLUGIN_MANAGER -DHAS_MINUIT2 -DR__HAS_MATHMORE") -# making library +# --- making library --- add_library( ${library_name} STATIC @@ -33,25 +33,13 @@ add_library( ) #set_Target_properties(${library_name} PROPERTIES PREFIX ${libprefix} SUFFIX ${libsuffix}) #set(${library_name}_LIBRARY_TYPE SHARED) - -# external dependencies -include_directories(${GSL_INCLUDE_DIRS}) -target_link_libraries(${library_name} ${GSL_LIBRARIES}) - -# copying library into lib directory for functional tests -#ADD_CUSTOM_COMMAND( -# TARGET ${library_name} -# POST_BUILD -# COMMAND ${CMAKE_COMMAND} -E copy -# ${libprefix}${library_name}${libsuffix} -# ${CMAKE_BINARY_DIR}/lib -#) - # exposing library name and list of include directories outside set(${library_name}_INCLUDE_DIRS ${include_dirs} PARENT_SCOPE) set(${library_name}_LIBRARY ${library_name} PARENT_SCOPE) -# ----------------------------------------------- -# installation -# ----------------------------------------------- +# --- external dependencies --- +include_directories(${GSL_INCLUDE_DIRS}) +target_link_libraries(${library_name} ${GSL_LIBRARIES}) + +# --- installation --- install (TARGETS ${library_name} DESTINATION lib COMPONENT Libraries) diff --git a/cmake/modules/SearchInstalledSoftware.cmake b/cmake/modules/SearchInstalledSoftware.cmake index dfa83d93b36..95c6d86e5a8 100644 --- a/cmake/modules/SearchInstalledSoftware.cmake +++ b/cmake/modules/SearchInstalledSoftware.cmake @@ -1,3 +1,4 @@ +# Search for installed software required by BornAgain # --- Eigen3 --- find_package(Eigen3 3.1.0) @@ -5,34 +6,21 @@ if(NOT EIGEN3_FOUND) set(EIGEN3_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/ThirdParty/eigen3) message(STATUS "--> Build in version of Eigen3 will be used") endif() -include_directories(${EIGEN3_INCLUDE_DIR}) # --- FFTW3 --- find_package(FFTW REQUIRED) -include_directories(${FFTW_INCLUDE_DIR}) - -# --- Boost --- -if(WIN32) - set(BOOST_ROOT "C:/opt/local") -endif() - -#set(Boost_USE_STATIC_LIBS ON) -#set(Boost_USE_MULTITHREADED ON) -##set(boost_libraries_required program_options iostreams system filesystem regex thread) -#set(boost_libraries_required date_time chrono program_options zlib iostreams system filesystem regex thread) +# --- BOOST --- set(Boost_USE_STATIC_LIBS OFF) set(Boost_USE_MULTITHREADED ON) set(Boost_USE_STATIC_RUNTIME OFF) -#set(BOOST_ALL_DYN_LINK ON) add_definitions(-DBOOST_ALL_DYN_LINK) # line is needed for MSVC -#add_definitions(-DBOOST_LIB_DIAGNOSTIC) # shows during compilation linked libraries +#add_definitions(-DBOOST_LIB_DIAGNOSTIC) # shows during compilation auto-linked libraries if(WIN32) -set(boost_libraries_required date_time chrono program_options zlib bzip2 iostreams system filesystem regex thread) + set(boost_libraries_required date_time chrono program_options zlib bzip2 iostreams system filesystem regex thread) else() -set(boost_libraries_required date_time chrono program_options iostreams system filesystem regex thread) + set(boost_libraries_required date_time chrono program_options iostreams system filesystem regex thread) endif() - if(BORNAGAIN_PYTHON) list(APPEND boost_libraries_required python) endif() @@ -42,50 +30,46 @@ find_package(Boost 1.48.0 COMPONENTS ${boost_libraries_required} REQUIRED) #message(STATUS "Boost_LIBRARIES: ${Boost_LIBRARIES}") # --- GSL --- -if(NOT BUILTIN_GSL) - find_package(GSL REQUIRED) - if(GSL_FOUND) - include_directories(${GSL_INCLUDE_DIR}) - else() - message(STATUS "No GSL has been found. Install it, or run cmake -DBUILTIN_GSL=ON to use build in GSL installation.") - endif() -endif() -if(BUILTIN_GSL) - set(gsl_version 1.9) - include(ExternalProject) - message(STATUS "Downloading and building GSL version ${gsl_version}") - ExternalProject_Add( - GSL - URL http://mirror.switch.ch/ftp/mirror/gnu/gsl/gsl-${gsl_version}.tar.gz - INSTALL_DIR ${CMAKE_BINARY_DIR} - CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix <INSTALL_DIR> --disable-shared - ) - set(GSL_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/include) - set(GSL_LIBRARIES -L${CMAKE_BINARY_DIR}/lib -lgsl -lgslcblas -lm) -endif() +find_package(GSL REQUIRED) + +#if(NOT BUILTIN_GSL) +# find_package(GSL REQUIRED) +# if(GSL_FOUND) +# include_directories(${GSL_INCLUDE_DIR}) +# else() +# message(STATUS "No GSL has been found. Install it, or run cmake -DBUILTIN_GSL=ON to use build in GSL installation.") +# endif() +#endif() + +#if(BUILTIN_GSL) +# set(gsl_version 1.9) +# include(ExternalProject) +# message(STATUS "Downloading and building GSL version ${gsl_version}") +# ExternalProject_Add( +# GSL +# URL http://mirror.switch.ch/ftp/mirror/gnu/gsl/gsl-${gsl_version}.tar.gz +# INSTALL_DIR ${CMAKE_BINARY_DIR} +# CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix <INSTALL_DIR> --disable-shared +# ) +# set(GSL_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/include) +# set(GSL_LIBRARIES -L${CMAKE_BINARY_DIR}/lib -lgsl -lgslcblas -lm) +#endif() # --- Python --- if(BORNAGAIN_PYTHON) - find_package(PythonInterp) # important to find interpreter and libraries from same python version set(PythonLibs_FIND_VERSION ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) - find_package(PythonLibs REQUIRED) - if(PYTHONLIBS_FOUND) - include_directories(${PYTHON_INCLUDE_DIRS}) - else() - message(SEND_ERROR "No python libraries have been found") + if(NOT PYTHONLIBS_FOUND) + message(SEND_ERROR "No python libraries have been found") endif() - find_package(Numpy REQUIRED) - include_directories(${NUMPY_INCLUDE_DIR}) - endif() # --- ROOT --- find_package(ROOT) -if(ROOT_FOUND) - include_directories(${ROOT_INCLUDE_DIR}) -endif() +#if(ROOT_FOUND) +# include_directories(${ROOT_INCLUDE_DIR}) +#endif() -- GitLab