diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2024-07-03 10:19:36 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2024-07-03 10:19:36 +0200 |
commit | b6bd52cd7330a90fc0e44dbe6022551a8dd768a1 (patch) | |
tree | 9804282102f8c40d27407b9c94119b35eeb5013c /app/bin/CMakeLists.txt | |
parent | c9d0740841fbe0539e42e66d3865672bfcd3ac02 (diff) | |
parent | a14a7a0ccc9de76aeab0b2e4bbf58f1a79deedc2 (diff) |
Update upstream source from tag 'upstream/5.3.0GA'
Update to upstream version '5.3.0GA'
with Debian dir dfd14d63b0238e276ade6f54dd9100325df5b2f9
Diffstat (limited to 'app/bin/CMakeLists.txt')
-rw-r--r-- | app/bin/CMakeLists.txt | 631 |
1 files changed, 352 insertions, 279 deletions
diff --git a/app/bin/CMakeLists.txt b/app/bin/CMakeLists.txt index 8d28205..48a0b72 100644 --- a/app/bin/CMakeLists.txt +++ b/app/bin/CMakeLists.txt @@ -1,18 +1,64 @@ +project(xtrkcad-lib) + include( CheckSymbolExists ) +# +# Create line symbols for turnouts from src definitions +# +# 1. Build converter cnvdsgn +# 2. define target "lines" for all symols +# 3. create .lin-files using converter +# 4. add individual .lin-files as dependency to "lines" +# + +# build GA or Beta executable +set( XTRKCAD_BIN "xtrkcad${XTRKCAD_BETA}" ) + +add_subdirectory(bitmaps) + +add_executable(cnvdsgn cnvdsgn.c utility.c) + +target_link_libraries(cnvdsgn xtrkcad-wlib) + +if(NOT WIN32) + target_link_libraries(cnvdsgn m) +endif() + +add_custom_target(lines + DEPENDS cnvdsgn +) + +# +# macro to copy DLLs into build directory +# eases debugging on Windows +# +if(WIN32) + macro(COPYDLLTOBUILD dllname) + add_custom_command( + TARGET xtrkcad POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${dllname} + ${CMAKE_CURRENT_BINARY_DIR} + ) + endmacro(COPYDLLTOBUILD) +endif() -ADD_EXECUTABLE(cnvdsgn cnvdsgn.c utility.c) -IF(NOT WIN32) - TARGET_LINK_LIBRARIES(cnvdsgn m) -ENDIF(NOT WIN32) +# +# macro creates lin files and adds the result as dependency +# -MACRO(GENERATE_LIN lin_name) - ADD_CUSTOM_COMMAND( +macro(GENERATE_LIN lin_name) + add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${lin_name}.lin - DEPENDS cnvdsgn ${CMAKE_CURRENT_SOURCE_DIR}/${lin_name}.src + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${lin_name}.src COMMAND cnvdsgn < ${CMAKE_CURRENT_SOURCE_DIR}/${lin_name}.src > ${CMAKE_CURRENT_BINARY_DIR}/${lin_name}.lin - ) -ENDMACRO(GENERATE_LIN) + ) + + target_sources(lines + PRIVATE + ${CMAKE_CURRENT_BINARY_DIR}/${lin_name}.lin + ) +endmacro(GENERATE_LIN) GENERATE_LIN(to3way) GENERATE_LIN(tocrv) @@ -30,314 +76,341 @@ GENERATE_LIN(tocornu) GENERATE_LIN(tocornuwye) GENERATE_LIN(tocornu3way) -SET(LIN_SOURCES - ${CMAKE_CURRENT_BINARY_DIR}/to3way.lin - ${CMAKE_CURRENT_BINARY_DIR}/tocrv.lin - ${CMAKE_CURRENT_BINARY_DIR}/tocrvsct.lin - ${CMAKE_CURRENT_BINARY_DIR}/todcross.lin - ${CMAKE_CURRENT_BINARY_DIR}/todslip.lin - ${CMAKE_CURRENT_BINARY_DIR}/tolcross.lin - ${CMAKE_CURRENT_BINARY_DIR}/torcross.lin - ${CMAKE_CURRENT_BINARY_DIR}/toreg.lin - ${CMAKE_CURRENT_BINARY_DIR}/tosslip.lin - ${CMAKE_CURRENT_BINARY_DIR}/tostrsct.lin - ${CMAKE_CURRENT_BINARY_DIR}/towye.lin - ${CMAKE_CURRENT_BINARY_DIR}/toxing.lin - ${CMAKE_CURRENT_BINARY_DIR}/tocornu.lin - ${CMAKE_CURRENT_BINARY_DIR}/tocornuwye.lin - ${CMAKE_CURRENT_BINARY_DIR}/tocornu3way.lin - ) - -ADD_CUSTOM_COMMAND( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/bllnhlp.c - DEPENDS genhelp ${help_SOURCE_DIR}/genhelp.json - COMMAND genhelp ${GENHELP_OPTS} ${help_SOURCE_DIR}/genhelp.json ${CMAKE_CURRENT_BINARY_DIR}/bllnhlp.c - ) - -ADD_EXECUTABLE(xtrkcad WIN32 - misc.c - xtrkcad.rc +# put these targets into the folder LineSymbols +set_target_properties(lines cnvdsgn PROPERTIES FOLDER LineSymbols) + +add_library(xtrkcad-lib "") + +target_sources(xtrkcad-lib + PRIVATE + appdefaults.c + archive.c + archive.h + cbezier.c + cbezier.h + cblock.c + ccornu.c + ccornu.h + ccurve.c + ccurve.h + ccontrol.c + cdraw.c + celev.c + cgroup.c + chndldto.c + chotbar.c + cjoin.c + cjoin.h + cmisc.c + cmodify.c + cnote.c + command.c + command.h + common.h + common-ui.h + compound.c + compound.h + cparalle.c + cprint.c + cprofile.c + cpull.c + cruler.c + cselect.c + cselect.h + csensor.c + csnap.c + csplit.c + csignal.c + cstraigh.c + cstraigh.h + cstruct.c + cswitchmotor.c + ctext.c + ctodesgn.c + ctrain.c + ctrain.h + cturnout.c + cturntbl.c + cundo.c + cundo.h + custom.c + custom.h + dbench.c + dbitmap.c + dcar.c + dcmpnd.c + dcustmgm.c + dcontmgm.c + dease.c + denum.c + directory.c + directory.h + dlayer.c + dlayer.h + doption.c + dpricels.c + dprmfile.c + draw.c + draw.h + drawgeom.c + drawgeom.h + dxfformat.c + dxfformat.h + dxfoutput.c + elev.c + file2uri.c + file2uri.h + fileio.c + fileio.h + filenoteui.c + i18n.c + layout.c + layout.h + levenshtein.c + linknoteui.c + lprintf.c + macro.c + manifest.c + manifest.h + menu.h + menu.c + misc.c + misc.h + note.h + param.c + param.h + paramfile.c + paramfilelist.c + paramfilesearch_ui.c + partcatalog.c + paths.c + paths.h + problemrep.c + problemrepui.c + scale.c + scale.h + shortentext.c + shortentext.h + shrtpath.c + shrtpath.h + smalldlg.c + smalldlg.h + stringxtc.c + tbezier.c + tbezier.h + tcornu.c + tcornu.h + tcurve.c + tease.c + textnoteui.c + track.c + track.h + trackx.h + trkendpt.c + trkendpt.h + trkendptx.h + trknote.c + trkseg.h + trkseg.c + tstraigh.c + turnout.c + uthash.h + utility.c + utility.h + validator.c + validator.h + include/dirent.h + include/levenshtein.h + include/paramfile.h + include/paramfilelist.h + include/partcatalog.h + include/problemrep.h + include/stringxtc.h + include/utlist.h ) -SET(SOURCES - ${LIN_SOURCES} - appdefaults.c - archive.c - archive.h - bllnhlp.c - cbezier.c - cbezier.h - cblock.c - ccornu.c - ccornu.h - ccurve.c - ccurve.h - ccontrol.c - cdraw.c - celev.c - cgroup.c - chndldto.c - chotbar.c - cjoin.c - cjoin.h - cmisc.c - cmodify.c - cnote.c - common.h - common-ui.h - compound.c - compound.h - cparalle.c - cprint.c - cprofile.c - cpull.c - cruler.c - cselect.c - cselect.h - csensor.c - csnap.c - csplit.c - csignal.c - cstraigh.c - cstraigh.h - cstruct.c - cswitchmotor.c - ctext.c - ctodesgn.c - ctrain.c - cturnout.c - cturntbl.c - cundo.c - custom.c - custom.h - dbench.c - dbitmap.c - dcar.c - dcmpnd.c - dcustmgm.c - dcontmgm.c - dease.c - denum.c - directory.c - dlayer.c - doption.c - dpricels.c - dprmfile.c - draw.c - draw.h - drawgeom.c - dxfformat.c - dxfformat.h - dxfoutput.c - elev.c - file2uri.c - file2uri.h - fileio.c - filenoteui.c - i18n.c - layout.c - layout.h - levenshtein.c - linknoteui.c - lprintf.c - macro.c - manifest.c - misc.c - misc.h - misc2.c - param.c - paramfile.c - paramfilelist.c - paramfilesearch_ui.c - partcatalog.c - paths.c - shortentext.c - shrtpath.c - smalldlg.c - stringxtc.c - tbezier.c - tcornu.c - tcurve.c - tease.c - textnoteui.c - track.c - track.h - trackx.h - trknote.c - trkseg.c - tstraigh.c - utility.c - utility.h - validator.c - cJSON.c - archive.h - directory.h - manifest.h - validator.h - ) - # add UTF-8 conversion utilities on Windows + if(WIN32) - set( SOURCES - ${SOURCES} - utf8convert.c - include/utf8convert.h + target_sources(xtrkcad-lib + PRIVATE + utf8convert.c + include/utf8convert.h ) -endif(WIN32) - -set (SOURCES - ${SOURCES} - include/dirent.h - include/levenshtein.h - include/paramfile.h - include/paramfilelist.h - include/partcatalog.h - include/stringxtc.h - include/utlist.h +endif() + +# This ensures that messages.h has been generated before we build xtrkcad-lib +add_dependencies(xtrkcad-lib + msgfiles + lines + genbitmaps ) -if(XTRKCAD_CREATE_SVG) - set (SOURCES - ${SOURCES} - svgformat.c - svgoutput.c - ) - include_directories(${MINIXML_INCLUDE_PATH}) - if(WIN32) - add_custom_command( - TARGET xtrkcad POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${MINIXML_SHAREDLIB} - ${CMAKE_CURRENT_BINARY_DIR} - ) +target_include_directories(xtrkcad-lib + PUBLIC + ${messagefile_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} +) - # add dll to install package - install(FILES ${MINIXML_SHAREDLIB} - DESTINATION ${XTRKCAD_BIN_INSTALL_DIR} - ) - endif(WIN32) +target_link_libraries(xtrkcad-lib + PRIVATE + cJSON + dynstring + xtrkcad-cornu + xtrkcad-wlib +) -endif(XTRKCAD_CREATE_SVG) +if(UNIX AND NOT APPLE) + target_link_libraries(xtrkcad-lib PRIVATE ${LIBZIP_LIBRARY} ${LIBZIP_LIBRARIES} ${ZLIB_LIBRARY}) +else() + target_link_libraries(xtrkcad-lib + PRIVATE + Libzip::Libzip + FreeImage::FreeImage + Zlib::Zlib) +endif() -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) -INCLUDE_DIRECTORIES(${XTrkCAD_BINARY_DIR}) -INCLUDE_DIRECTORIES(${help_BINARY_DIR}) -INCLUDE_DIRECTORIES(${wlib_SOURCE_DIR}/include) -include_directories(${FREEIMAGE_INCLUDE_PATH}) -INCLUDE_DIRECTORIES(${LIBZIP_INCLUDE_DIR_ZIP}) -INCLUDE_DIRECTORIES(${CJSON_INCLUDE}) +# +# Start building the main program itself +# +add_executable(${XTRKCAD_BIN} WIN32 "" ) -LINK_DIRECTORIES(${GTK_LIBRARY_DIRS}) -LINK_DIRECTORIES(${GTK_WEBKIT_LIBRARY_DIRS}) -LINK_DIRECTORIES(${LIBZIP_LIBZIP_LIBRARY}) +# if SVG export is built and source files and dependency on MiniXML -ADD_LIBRARY(xtrkcad-lib ${SOURCES}) +if(XTRKCAD_CREATE_SVG) + target_sources(xtrkcad-lib + PRIVATE + svgformat.c + svgoutput.c + ) -# This ensures that messages.h has been generated before we build xtrkcad-lib -ADD_DEPENDENCIES(xtrkcad-lib Help) + if(WIN32) + target_link_libraries(xtrkcad-lib + PRIVATE + MiniXML::mxml + ) + endif() + if(UNIX) + if (APPLE OR NOT ${MINIXML_STATIC_LIBRARY}) + target_link_libraries(xtrkcad-lib + PRIVATE + MiniXML::mxml + ) + else() + target_link_libraries(xtrkcad ${MINIXML_STATIC_LIBRARY}) + target_link_libraries(xtrkcad "pthread") + endif() + endif() +endif() -TARGET_LINK_LIBRARIES(xtrkcad xtrkcad-lib) -TARGET_LINK_LIBRARIES(xtrkcad xtrkcad-wlib) -TARGET_LINK_LIBRARIES(xtrkcad xtrkcad-cornu) -TARGET_LINK_LIBRARIES(xtrkcad dynstring) -if(XTRKCAD_CREATE_SVG) -IF(UNIX) - if (NOT APPLE) - target_link_libraries(xtrkcad ${MINIXML_STATIC_LIBRARY}) - target_link_libraries(xtrkcad "pthread") - else(NOT APPLE) - target_link_libraries(xtrkcad ${MINIXML_LIBRARY}) - endif(NOT APPLE) -ELSE(UNIX) - target_link_libraries(xtrkcad ${MINIXML_STATIC_LIBRARY}) -ENDIF(UNIX) -endif(XTRKCAD_CREATE_SVG) - -IF(UNIX AND NOT APPLE) -target_link_libraries(xtrkcad ${LIBZIP_LIBRARY} ${LIBZIP_LIBRARIES} ${ZLIB_LIBRARY}) -ELSE(UNIX AND NOT APPLE) -target_link_libraries(xtrkcad ${LIBZIP_LIBRARY} ${LIBZIP_LIBRARIES}) -ENDIF(UNIX AND NOT APPLE) - -ADD_EXECUTABLE(mkturnout - ${LIN_SOURCES} - ctodesgn.c +target_sources(${XTRKCAD_BIN} + PRIVATE + misc.c + ${messagefile_BINARY_DIR}/bllnhlp.c + xtrkcad.rc +) +add_dependencies(${XTRKCAD_BIN} + balloonhelp + msgfiles + genbitmaps) + +target_include_directories(${XTRKCAD_BIN} + PRIVATE + ${messagefile_BINARY_DIR} +) + +target_link_libraries(${XTRKCAD_BIN} + PRIVATE + xtrkcad-wlib + xtrkcad-lib +) + +# +# Create mkturnout utility +# +add_executable(mkturnout + ctodesgn.c utility.c + trkendpt.c +) +set_target_properties(mkturnout PROPERTIES COMPILE_FLAGS -DMKTURNOUT) +set_target_properties(mkturnout PROPERTIES FOLDER "Param Files" ) - ) -SET_TARGET_PROPERTIES(mkturnout PROPERTIES COMPILE_FLAGS -DMKTURNOUT) +target_include_directories(mkturnout + PRIVATE + ${messagefile_BINARY_DIR} +) -TARGET_LINK_LIBRARIES(mkturnout xtrkcad-cornu) +target_link_libraries(mkturnout + PRIVATE + xtrkcad-wlib +) -IF(NOT WIN32) - TARGET_LINK_LIBRARIES(mkturnout m) - TARGET_LINK_LIBRARIES(xtrkcad m) +add_dependencies(mkturnout + msgfiles + lines +) + +if(NOT WIN32) + target_link_libraries(mkturnout + PRIVATE + m + ) + target_link_libraries(${XTRKCAD_BIN} + PRIVATE + m + ) # Link libintl for systems where it is a separate library find_library( INTL_LIBRARY intl ) if(INTL_LIBRARY) - target_link_libraries( mkturnout ${INTL_LIBRARY} ) - endif(INTL_LIBRARY) -ELSE(NOT WIN32) - TARGET_LINK_LIBRARIES(mkturnout xtrkcad-wlib) - + target_link_libraries( mkturnout + PRIVATE + ${INTL_LIBRARY} + ) + endif() +else() # copy dlls into the build dir for easier debugging - add_custom_command( - TARGET xtrkcad POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${FREEIMAGE_SHAREDLIB} - ${CMAKE_CURRENT_BINARY_DIR} - ) - - add_custom_command( - TARGET xtrkcad POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBZIP_SHAREDLIB} - ${CMAKE_CURRENT_BINARY_DIR} - ) - - add_custom_command( - TARGET xtrkcad POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${ZLIB_SHAREDLIB} - ${CMAKE_CURRENT_BINARY_DIR} - ) - + COPYDLLTOBUILD(${FREEIMAGE_SHAREDLIB}) +# COPYDLLTOBUILD(${LIBZIP_SHAREDLIB}) +# COPYDLLTOBUILD(${ZLIB_SHAREDLIB}) + set(ENV{path} "${CMAKE_CURRENT_BINARY_DIR};$ENV{PATH}") # add dll to install package - INSTALL( - FILES - ${LIBZIP_SHAREDLIB} + install( + FILES ${LIBZIP_SHAREDLIB} DESTINATION ${XTRKCAD_BIN_INSTALL_DIR} ) - INSTALL(FILES - ${ZLIB_SHAREDLIB} + install( + FILES ${ZLIB_SHAREDLIB} DESTINATION ${XTRKCAD_BIN_INSTALL_DIR} ) - # Copy program PDB file - INSTALL( - FILES $<TARGET_PDB_FILE:xtrkcad> - DESTINATION ${XTRKCAD_BIN_INSTALL_DIR} OPTIONAL + # Copy program PDB file + install( + FILES $<TARGET_PDB_FILE:xtrkcad> + DESTINATION ${XTRKCAD_BIN_INSTALL_DIR} + OPTIONAL ) -ENDIF(NOT WIN32) +endif() # for testing only, should be IF(APPLE) ... -IF(APPLE) - ADD_EXECUTABLE( helphelper helphelper.c ) - FIND_LIBRARY(COREFOUNDATION_LIBRARY CoreFoundation) - FIND_LIBRARY(CARBON_LIBRARY Carbon) - TARGET_lINK_LIBRARIES(helphelper ${COREFOUNDATION_LIBRARY} ${CARBON_LIBRARY}) - INSTALL( +if(APPLE) + add_executable( helphelper helphelper.c ) + find_library(COREFOUNDATION_LIBRARY CoreFoundation) + find_library(CARBON_LIBRARY Carbon) + target_link_libraries(helphelper ${COREFOUNDATION_LIBRARY} ${CARBON_LIBRARY}) + install( TARGETS helphelper RUNTIME DESTINATION ${XTRKCAD_BIN_INSTALL_DIR} ) -ENDIF(APPLE) +endif() -INSTALL( - TARGETS xtrkcad +install( + TARGETS ${XTRKCAD_BIN} RUNTIME DESTINATION ${XTRKCAD_BIN_INSTALL_DIR} - ) +) if(XTRKCAD_TESTING AND CMOCKA_FOUND) add_subdirectory( unittest ) |