File:  [Local Repository] / imach / CMakeLists.txt
Revision 1.26: download - view: text, annotated - select for diffs
Wed Mar 31 13:13:28 2021 UTC (3 years, 7 months ago) by brouard
Branches: MAIN
CVS tags: HEAD
Summary: Version 0.99r23

# if(CMAKE_CONFIGURATION_TYPES)
# #   set(CMAKE_CONFIGURATION_TYPES Debug Release DebugMX31 ReleaseMX31)
#    set(CMAKE_CONFIGURATION_TYPES Debug Release)
#    set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
#      "Reset the configurations to what we need"
#      FORCE)
#  endif()
# SET (CMAKE_CONFIGURATION_TYPES "Debug;RelWithDebinfo" CACHE STRING "" FORCE)
set(PACKAGE_NAME "imach")
SET(IMACH_VERSION_MAJOR 0)
SET(IMACH_VERSION_MINOR 99r23)
SET(IMACH_VERSION_PATCH 0)
SET(IMACH_VERSION_NOTE "")
SET(IMACH_VERSION ${IMACH_VERSION_MAJOR}.${IMACH_VERSION_MINOR})
SET(@APPNAME@ IMaCh-${IMACH_VERSION_MAJOR}.${IMACH_VERSION_MINOR})
SET(@NOTINNOREG@ )
SET(@NOREG@ )
SET(@IMACHSETUPVERSION@ imach-${IMACH_VERSION_MAJOR}.${IMACH_VERSION_MINOR}-icl-setup)
SET(@APPCOMPILATIONMODE@ icl)
SET(@VERSION@ ${IMACH_VERSION_MAJOR}.${IMACH_VERSION_MINOR})
SET(@GNUPLOTVERSION@ 5.1)
SET(@INFOBEFOREFILE@ README.txt)
SET(@LICENSEFILE@ Copying)
SET(@PACKAGE@ imach)
SET(@DICTLANG@ en)
SET(@VERMAJOR@ )
SET(@COPYRIGHT@ "Copyright (C)  2002-2015 EUROREVES-Institut de longevite-Japan Society for the Promotion of Science (Grant-in-Aid for Scientific Research 25293121) 2013-2016- Intel Software 2015-2018 2000-2021 INED")
#SET(IMACH_VERSION ${IMACH_VERSION_MAJOR}.${IMACH_VERSION_MINOR}.${IMACH_VERSION_PATCH})
#MATH(EXPR IMACH_VERSION_NUMBER "100000*${IMACH_VERSION_MAJOR} + 100*${IMACH_VERSION_MINOR} + ${IMACH_VERSION_PATCH}")

# #PROJECT(IMaCh${IMACH_VERSION_MAJOR})
PROJECT (IMaCh)

CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11)

CONFIGURE_FILE(
  "${PROJECT_SOURCE_DIR}/version.h.in"
  "${PROJECT_SOURCE_DIR}/src/version.h"
  )
CONFIGURE_FILE(
  "${PROJECT_SOURCE_DIR}/config.h.in"
  "${PROJECT_BINARY_DIR}/config.h"
)
# Examples for the documentation
CONFIGURE_FILE("${PROJECT_SOURCE_DIR}/tests/mypar.imach.in" "html/doc/mypar.imach")
CONFIGURE_FILE("${PROJECT_SOURCE_DIR}/tests/biaspar.imach.in" "html/doc/biaspar.imach")
CONFIGURE_FILE("${PROJECT_SOURCE_DIR}/tests/data1.txt" "html/doc/data1.txt" COPYONLY)
CONFIGURE_FILE("${PROJECT_SOURCE_DIR}/tests/data/mydata.txt" "html/doc/data/mydata.txt" COPYONLY)
# Test files
CONFIGURE_FILE("${PROJECT_SOURCE_DIR}/tests/data/data2.txt" "tests/data/data2.txt" COPYONLY)
#CONFIGURE_FILE("${PROJECT_SOURCE_DIR}/tests/testV2.imach" "tests/testV2.imach" COPYONLY)
#CONFIGURE_FILE("${PROJECT_SOURCE_DIR}/tests/testV1V2.imach" "tests/testV1V2.imach" COPYONLY)


set (imach_SRCS ./src/imach.c)
SET( CMAKE_VERBOSE_MAKEFILE on )
#SET(CMAKE_INSTALL_PREFIX "/usr/local")
ADD_EXECUTABLE (IMaCh-${IMACH_VERSION_MAJOR}.${IMACH_VERSION_MINOR} ${imach_SRCS})
INSTALL(TARGETS IMaCh-${IMACH_VERSION_MAJOR}.${IMACH_VERSION_MINOR} DESTINATION bin COMPONENT binaries )
#INSTALL(TARGETS imach DESTINATION bin COMPONENT binaries )
ADD_SUBDIRECTORY(html)
ADD_SUBDIRECTORY(tests)
#ADD_SUBDIRECTORY(src) 
#ADD_SUBDIRECTORY(distributions)
#if (${WIN32})
#if(APPLE)
#  set(DOCDIR "${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/doc")
#endif()
if(UNIX)
  #   set(CMAKE_CXX_COMPILER "gcc")
  target_link_libraries(IMaCh-${IMACH_VERSION_MAJOR}.${IMACH_VERSION_MINOR} m)
  set(BINDIR "${CMAKE_INSTALL_PREFIX}/bin")
  set(DOCDIR "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/doc")
  set(TESTDIR "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/tests")
  set(DATADIR "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/tests/data")
  set(MANDIR "${CMAKE_INSTALL_PREFIX}/share/man/man1")
  #set(EXAMPLE_CONF_DIR ${DOCDIR})
  set(XDG_APPS_DIR "${CMAKE_INSTALL_PREFIX}/share/applications")
  set(APPDATADIR "${CMAKE_INSTALL_PREFIX}/share/appdata")
  set(ICONDIR "${CMAKE_INSTALL_PREFIX}/share/icons")
  install(FILES "distributions/gnulinux/imach.1" DESTINATION "${MANDIR}")
  install(FILES "distributions/gnulinux/imach.png" DESTINATION "${ICONDIR}")
  install(FILES "distributions/gnulinux/imach.desktop" DESTINATION "${XDG_APPS_DIR}")
endif()
if(MSVC)
  set(DOCDIR "${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/doc")
  set(TESTDIR "${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/tests")
  set(DATADIR "${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/tests/data")
  set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
  set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
  set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
  set(CMAKE_CONFIGURATION_TYPES:STRING=Release)
  ADD_DEFINITIONS( -DCONSOLE)
  ADD_DEFINITIONS( -D_CONSOLE)
endif()
ADD_DEFINITIONS( -DCROSS=0)

install(FILES "html/doc/mypar.imach" DESTINATION "${DOCDIR}")
install(FILES "html/doc/data/mydata.txt" DESTINATION "${DOCDIR}/data")
install(FILES "html/doc/biaspar.imach" DESTINATION "${DOCDIR}")
install(FILES "html/doc/data1.txt" DESTINATION "${DOCDIR}")
install(FILES "src/README.txt" DESTINATION "${DOCDIR}")
#install(FILES "tests/testV1V2.imach" DESTINATION "${TESTDIR}")
install(FILES "tests/rtestV1V2.imach" DESTINATION "${TESTDIR}")
install(FILES "tests/testV2.imach" DESTINATION "${TESTDIR}")
install(FILES "tests/rtestV2.imach" DESTINATION "${TESTDIR}")
install(FILES "tests/data/data2.txt" DESTINATION "${DATADIR}")
#not working install(FILES "imach.desktop" DESTINATION "${XDG_APPS_DIR}")
#install(FILES "html" DESTINATION "${DOCDIR}")


set(CPACK_PACKAGE_VERSION ${IMACH_VERSION})
set(CPACK_PACKAGE_NAME "imach")
set(CPACK_PACKAGE_RELEASE 1)
set(CPACK_PACKAGE_CONTACT "Nicolas Brouard")
set(CPACK_PACKAGE_VENDOR "INED")
SET(CPACK_PACKAGE_VENDOR "IMaCh, INED")
SET(CPACK_PACKAGE_LICENSE "GPLv2")
#SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.txt")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt")
SET(CPACK_PACKAGE_VERSION_MAJOR "${IMACH_VERSION_MAJOR}")
SET(CPACK_PACKAGE_VERSION_MINOR "${IMACH_VERSION_MINOR}")
SET(CPACK_PACKAGE_VERSION_PATCH "${IMACH_VERSION_PATCH}")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}")
#SET(CPACK_INSTALLED_DIRECTORIES "${PROJECT_SOURCE_DIR}" ".")
#SET(CPACK_PACKAGE_EXECUTABLES "IMaCh" "IMaCh")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "IMaCh program estimates Health Expectancies from Cross-longitudinal surveys.")
#SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.txt")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/imach-desc.txt")
set(CPACK_RPM_PACKAGE_URL "http://euroreves.ined.fr/imach")
IF(UNIX)
  SET(CPACK_RPM_PACKAGE_LICENSE "GPL")
  SET(CPACK_RPM_PACKAGE_GROUP "Applications/Sciences")
  SET(CPACK_RPM_PACKAGE_REQUIRES "gnuplot >= 4.2, cmake >= 2.8")
  SET(CPACK_GENERATOR "TXZ")
  SET(CPACK_SOURCE_GENERATOR "TXZ")
  SET(CPACK_SOURCE_TBZ2 "OFF")
  SET(CPACK_SOURCE_TGZ "ON")
  SET(CPACK_SOURCE_TOPLEVEL_TAG "Linux-src")
  SET(CPACK_SOURCE_TXZ "ON")
  SET(CPACK_SOURCE_TZ "ON")
  SET(CPACK_SOURCE_ZIP "OFF")
  #SET(CPACK_RPM_PREFIX "/usr/local")
  # SET(CPACK_RPM_PACKAGE_PREFIX "/usr/local")
   SET(CPACK_PACKAGING_INSTALL_PREFIX "/usr/local")
  # SET(CMAKE_INSTALL_PREFIX "/usr/local")
  set(CPACK_RPM_PACKAGE_RELOCATABLE True)
  # This a .spec Changelog not an Emacs ChangeLog that you get with C-x v a (vc-update-change-log)
  # * Mon May 20 2019  Brouard Nicolas  <brouard@brouard.name>
  # ${CMAKE_CURRENT_SOURCE_DIR}/specchangelog")
  set(CPACK_RPM_CHANGELOG_FILE "${PROJECT_SOURCE_DIR}/src/Changelog")
  SET(CPACK_BINARY_RPM "ON")
  SET(CPACK_RPM_PACKAGE_SOURCES "ON")
  set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.${CMAKE_SYSTEM_PROCESSOR}")
  SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.src")
ENDIF(UNIX)

IF(WIN32 AND NOT UNIX)
  # There is a bug in NSI that does not handle full unix paths properly. Make
  # sure there is at least one set of four (4) backlasshes.
  SET(CPACK_PACKAGE_ICON "${CMake_SOURCE_DIR}/Utilities/Release\\\\InstallIcon.bmp")
  SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\imach.exe")
  SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} IMaCh")
  SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\euroreves.ined.fr/imach/wiki")
  SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\euroreves.ined.fr/imach")
  SET(CPACK_NSIS_CONTACT "brouard@ined.fr")
  SET(CPACK_NSIS_MODIFY_PATH ON)
ELSE(WIN32 AND NOT UNIX)
  SET(CPACK_STRIP_FILES "bin/imach")
  SET(CPACK_SOURCE_STRIP_FILES "")
ENDIF(WIN32 AND NOT UNIX)
#SET(CPACK_PACKAGE_EXECUTABLES "IMaCh" "IMaCh")
INCLUDE(CPack)

  # set (CMAKE_GENERATOR_TOOLSET "v120_xp" CACHE STRING "BasePlatform toolset" FORCE)
  # ADD_DEFINITIONS(-D_USING_V110_SDK71_)
  # ADD_DEFINITIONS( -D_ATL_XP_TARGETING)
  # SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE,5.01")
  # set(CMAKE_C_FLAGS "/D_CONSOLE /D_ATL_XP_TARGETING /D_UNICODE")
  #set(CMAKE_GENERATOR_TOOLSET "v120_xp" CACHE STRING "Platform toolset" FORCE)
  #set("CMAKE_GENERATOR_TOOLSET", "vc120_xp")
  # set (CMAKE_GENERATOR_TOOLSET "Intel C++ Compiler XE 15.0" CACHE STRING "Platform Toolset" FORCE)
  #set (CMAKE_GENERATOR_TOOLSET "v120_xp" CACHE STRING "Platform toolset" FORCE)
  #set (CMAKE_VS_PLATFORM_TOOLSET "v120_xp" CACHE STRING "Platform toolset" FORCE)
  ##set (CMAKE_VS_PLATFORM_TOOLSET "v120_xp" CACHE STRING "BasePlatform toolset" FORCE)

   #https://software.intel.com/en-us/node/522398
    #    Using the msbuild.exe command line tool, use the /p:PlatformToolset and /p:BasePlatformToolset options. Example: When the Platform Toolset property is already set to use the Intel C++ compiler, to build a project using the Visual Studio 2010 environment use the following command:

    # Msbuild.exe myproject.vcxproj /p:BasePlatformToolset=v100

    # Example: To explicitly set the Platform Toolset property to use the Intel C++ compiler and build a project using the Visual Studio 2010 environment use the following command:

    # Msbuild.exe myproject.vcxproj /p:PlatformToolset=“Intel C++ Compiler XE 15.0” /p:BasePlatformToolset=v100
    # Msbuild.exe myproject.vcxproj /p:PlatformToolset=“Intel C++ Compiler XE 15.0” /p:BasePlatformToolset=v120_xp
# <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'" Label="Configuration">
#     <ConfigurationType>Application</ConfigurationType>
#     <UseOfMfc>false</UseOfMfc>
#     <CharacterSet>MultiByte</CharacterSet>
#     <PlatformToolset>Intel C++ Compiler XE 15.0</PlatformToolset>
#     <BasePlatformToolset>v120_xp</BasePlatformToolset>
#   </PropertyGroup>

   #set (BASEPLATFORMTOOLSET "v120_xp")
# set(VERSION_MAJOR "0")
# set(VERSION_MINOR "7")

# IF(NOT DEFINED BUILD_VERSION_PATCH)
#   set(VERSION_PATCH "0")
# else()
#   set(VERSION_PATCH "${BUILD_VERSION_PATCH}")
# ENDIF()
file( GLOB_RECURSE parameter_files RELATIVE
"${CMAKE_CURRENT_SOURCE_DIR}/html/doc" "html/*.imach" "tests/*.imach" )
foreach( parameter_file ${parameter_files} )
  add_custom_command(
    OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${parameter_file}"
    COMMAND cmake -E copy
"${CMAKE_CURRENT_SOURCE_DIR}/${parameter_file}"
"${CMAKE_CURRENT_BINARY_DIR}/${parameter_file}"
    DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${parameter_file}"
  )
  list( APPEND parameter_files_dest "${parameter_file}" )
endforeach( parameter_file )

#add_custom_target( CopyParameter ALL DEPENDS ${parameter_files_dest} )
ENABLE_TESTING()
#ADD_SUBDIRECTORY(html/doc)
#ADD_SUBDIRECTORY(html/doc/data)
#install(FILES "${PROJECT_SOURCE_DIR}/html/doc/mypar.imach" DESTINATION "html/doc")
ADD_TEST(testV2.imach  IMaCh-${IMACH_VERSION} tests/testV2.imach )
ADD_TEST(testV1V2.imach  IMaCh-${IMACH_VERSION} tests/testV1V2.imach )
ADD_TEST(mypar  IMaCh-${IMACH_VERSION} local/html/doc/ )
ADD_TEST(biaspar  IMaCh-${IMACH_VERSION} local/html/doc/ )
#SET(FAB "po" CACHE STRING "Some user-specified option")
#set_target_properties(TARGET_NAME imach-${VERSION_MAJOR}.${VERSION_MINOR})
#%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\VsDevCmd.bat""
#"C:\Program Files (x86)\Intel\Composer XE 2015\bin\ipsxe-comp-vars.bat" ia32 vs2013
#"C:\Program Files (x86)\Intel\Composer XE 2015\bin\ipsxe-comp-vars.bat" intel64 vs2013
#cmake ../../src -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS_RELEASE:STRING="/MD /O2 /Ob2 /D NDEBUG"
#G:\imach\imach-gui\build\icl32> msbuild IMaCh-0.98q3.vcxproj /t:Build /p:Configuration=Release
#G:\imach\imach-gui\build\vs32>"C:\Program Files (x86)\Common Files\Intel\shared files\ia32\Bin\ICProjConvert150" IMaCh.vcxproj /IC:"Intel C++ Compiler XE 15.0"
#"C:\Program Files (x86)\Common Files\Intel\shared files\ia32\Bin
##https://tedwvc.wordpress.com/2014/01/01/how-to-target-xp-with-vc2012-or-vc2013-and-continue-to-use-the-windows-8-x-sdk/
#elseif(MSVC)
#message(FATAL_ERROR "Fatal error")
# # set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/bin")
# # set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/bin")
# # set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/bin")
# # set(CMAKE_GENERATOR_TOOLSET "v120_xp" CACHE STRING "Platform toolset" FORCE)
# # add_subdirectory(src)
# # add_subdirectory(test)
#CMAKE_CONFIGURATION_TYPES:STRING=Debug;Release;MinSizeRel;RelWithDebInfo
# # OPTION(MYPROJECT_DEBUG
# #   "Build the project using debugging code"
# #   ON)
# # IF(MYPROJECT_DEBUG)
# #   SET_SOURCE_FILE_PROPERTIES(
# #     imach.c
# #     COMPILE_FLAGS -DDEBUG)
# # ENDIF(MYPROJECT_DEBUG)
# if (${WIN32})
#   link_directories(
#   )
  
#   add_definitions(
#     -DDEFINE1
#   )

#   target_link_libraries(
#     ${PROJECT_NAME} 
#     wsock32.lib 
#   )
# endif()
# if(MSVC OR MSVC_IDE)
#   if( MSVC_VERSION LESS 1700 )       # VC10-/VS2010-
#     message(FATAL_ERROR "The project requires C++11 features. "
#       "You need at least Visual Studio 11 (Microsoft Visual Studio 2012), "
#       "with Microsoft Visual C++ Compiler Nov 2012 CTP (v120_CTP_Nov2012).")
#   elseif( MSVC_VERSION EQUAL 1700 )  # VC11/VS2012
#     message( "VC11: use Microsoft Visual Studio 2012 "
#       "with Microsoft Visual C++ Compiler Nov 2012 CTP (v120_CTP_Nov2012)" )
#     set(CMAKE_GENERATOR_TOOLSET "v120_CTP_Nov2012" CACHE STRING "Platform Toolset" FORCE)
#   else() # VC12+, assuming C++11 supported.
#   endif()
# endif()
# Add a target to generate API documentation with Doxygen
option(BUILD_DOC "Build documentation" ON)
if(UNIXDODOXYGEN)
  find_package(Doxygen)
  if(DOXYGEN_FOUND)# set input and output files
    #set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/../docs/Doxyfile.in) ~/Documents/imach/cvs/imach/latex/Doxyfile.in
    set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/latex/Doxyfile.in)
    set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
    
    # request to configure the file
    configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
    message("Doxygen build started")
    
    # note the option ALL which allows to build the docs together with the application
    add_custom_target( doc_doxygen ALL
      COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
      COMMENT "Generating API documentation with Doxygen in gnulinux/html/index.html"
      VERBATIM )
    install(DIRECTORY ${CMAKE_BINARY_DIR}/html 
      DESTINATION local/share/doc/${CMAKE_PROJECT_NAME})
  else (DOXYGEN_FOUND)
    message("Doxygen need to be installed to generate the doxygen documentation")
  endif (DOXYGEN_FOUND)
  message("Doxygen only in UNIX doxygen documentation")
endif (UNIXDODOXYGEN)


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>