diff options
Diffstat (limited to 'app/bin/CMakeLists.txt')
-rw-r--r-- | app/bin/CMakeLists.txt | 569 |
1 files changed, 358 insertions, 211 deletions
diff --git a/app/bin/CMakeLists.txt b/app/bin/CMakeLists.txt index 2dea1bc..48a0b72 100644 --- a/app/bin/CMakeLists.txt +++ b/app/bin/CMakeLists.txt @@ -1,17 +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) -ADD_EXECUTABLE(cnvdsgn cnvdsgn.c utility.c) -IF(NOT WIN32) - TARGET_LINK_LIBRARIES(cnvdsgn m) -ENDIF(NOT WIN32) +target_link_libraries(cnvdsgn xtrkcad-wlib) + +if(NOT WIN32) + target_link_libraries(cnvdsgn m) +endif() + +add_custom_target(lines + DEPENDS cnvdsgn +) -MACRO(GENERATE_LIN lin_name) - ADD_CUSTOM_COMMAND( +# +# 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() + + +# +# macro creates lin files and adds the result as dependency +# + +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) @@ -29,241 +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 - ) +# put these targets into the folder LineSymbols +set_target_properties(lines cnvdsgn PROPERTIES FOLDER LineSymbols) -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 - ) - -SET(SOURCES - ${LIN_SOURCES} - appdefaults.c - archive.c - bllnhlp.c - cbezier.c - cblock.c - ccornu.c - ccurve.c - ccontrol.c - cdraw.c - celev.c - cgroup.c - chndldto.c - chotbar.c - cjoin.c - cmisc.c - cmodify.c - cnote.c - compound.c - cparalle.c - cprint.c - cprofile.c - cpull.c - cruler.c - cselect.c - csensor.c - csnap.c - csplit.c - csignal.c - cstraigh.c - cstruct.c - cswitchmotor.c - ctext.c - ctodesgn.c - ctrain.c - cturnout.c - cturntbl.c - cundo.c - custom.c - 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 - drawgeom.c - dxfformat.c - dxfoutput.c - elev.c - file2uri.c - file2uri.h - fileio.c - filenoteui.c - i18n.c - layout.c - linknoteui.c - lprintf.c - macro.c - manifest.c - 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 - trknote.c - trkseg.c - tstraigh.c - utility.c - validator.c - cJSON.c - archive.h - directory.h - manifest.h - validator.h - ) +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 +) # 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) +endif() -set (SOURCES - ${SOURCES} - include/dirent.h - include/paramfile.h - include/paramfilelist.h +# This ensures that messages.h has been generated before we build xtrkcad-lib +add_dependencies(xtrkcad-lib + msgfiles + lines + genbitmaps ) -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}) -LINK_DIRECTORIES(${GTK_LIBRARY_DIRS}) -LINK_DIRECTORIES(${GTK_WEBKIT_LIBRARY_DIRS}) -LINK_DIRECTORIES(${LIBZIP_LIBZIP_LIBRARY}) +target_include_directories(xtrkcad-lib + PUBLIC + ${messagefile_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} +) -ADD_LIBRARY(xtrkcad-lib ${SOURCES}) +target_link_libraries(xtrkcad-lib + PRIVATE + cJSON + dynstring + xtrkcad-cornu + xtrkcad-wlib +) -# This ensures that messages.h has been generated before we build xtrkcad-lib -ADD_DEPENDENCIES(xtrkcad-lib Help) +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() + +# +# Start building the main program itself +# +add_executable(${XTRKCAD_BIN} WIN32 "" ) -ADD_EXECUTABLE(xtrkcad WIN32 - misc.c - xtrkcad.rc +# if SVG export is built and source files and dependency on MiniXML + +if(XTRKCAD_CREATE_SVG) + target_sources(xtrkcad-lib + PRIVATE + svgformat.c + svgoutput.c ) -TARGET_LINK_LIBRARIES(xtrkcad xtrkcad-lib) -TARGET_LINK_LIBRARIES(xtrkcad xtrkcad-wlib) -TARGET_LINK_LIBRARIES(xtrkcad xtrkcad-cornu) -TARGET_LINK_LIBRARIES(xtrkcad dynstring) -target_link_libraries(xtrkcad ${LIBZIP_LIBRARY} ${LIBZIP_LIBRARIES}) - -ADD_EXECUTABLE(mkturnout - ${LIN_SOURCES} - ctodesgn.c + + 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_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 +) + +add_dependencies(mkturnout + msgfiles + lines +) -IF(NOT WIN32) - TARGET_LINK_LIBRARIES(mkturnout m) - TARGET_LINK_LIBRARIES(xtrkcad m) +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} + 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} + DESTINATION ${XTRKCAD_BIN_INSTALL_DIR} ) - - add_custom_command( - TARGET xtrkcad POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${ZLIB_SHAREDLIB} - ${CMAKE_CURRENT_BINARY_DIR} + install( + FILES ${ZLIB_SHAREDLIB} + DESTINATION ${XTRKCAD_BIN_INSTALL_DIR} ) - # add dll to install package - install(FILES - ${LIBZIP_SHAREDLIB} - DESTINATION ${XTRKCAD_BIN_INSTALL_DIR} + # Copy program PDB file + install( + FILES $<TARGET_PDB_FILE:xtrkcad> + DESTINATION ${XTRKCAD_BIN_INSTALL_DIR} + OPTIONAL ) - install(FILES - ${ZLIB_SHAREDLIB} - DESTINATION ${XTRKCAD_BIN_INSTALL_DIR} - ) -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 ) |