POV-Ray : Newsgroups : povray.beta-test : Windows XP compatibility : Re: Windows XP compatibility Server Time
6 Nov 2024 16:41:32 EST (-0500)
  Re: Windows XP compatibility  
From: Warren
Date: 7 Aug 2021 06:10:00
Message: <web.610e5b27d5a68e3b1d602a3e756b296@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 06.08.2021 um 21:04 schrieb Warren:
>

> Also, I may be misunderstanding things, but I presume CMake does not
> natively cater to a project that has, in some sense, completely
> different applications for different target platforms, which "only"
> share a common core.

You can mark out parts in a 'CMakeLists.txt' file like for example:

if( UNIX )
//Do these things only for Unix OSes
endif( UNIX )

if( WIN32 )
//Only for Windows OSes
endif( WIN32 )

And you also can make sub project like I do for the games I'm currently
developping like in this tree example: (directory based interpretation)

CMakeLists.txt in main project directory
|
|--'editor' sub directory that contains also a 'CMakeLists.txt' file that
generates an executable based partly on some others static libraries below, to
edit levels for the game
|--'inGame' sub directory that contains a 'CMakeLists.txt' that will build a
static library which is the game core
|--sdl2_wrapper : another static library that wraps the well known SDL2 library
so that it becomes RAII / RFID compliant ( C++ )
|--'game' generates the game excutable based on other libraries

That said I agree with you when you say CMake for now, can't generate a build
process based on a directory that may contains all the sources. But I make up
for that with a couples of commands in Ubuntu in a script shell:

#!/bin/bash
#List the sources and headers of 'inGame' directory
#
find ../sources/inGame -type f -name "*.h" > lists/inGameHeaders.txt
find ../sources/inGame -type f -name "*.cpp" > lists/inGameSources.txt
#
sed 's#../sources/inGame/#\t\t#g' -i lists/inGame*.txt

The last sed command adds two tabulation chars ('\t') so that when I paste the
txt file content , I have a suitable indentation.
And as concrete example here is a simple CMakeLists.txt :

cmake_minimum_required(VERSION 3.8)

project("game_${SQUARE_SIZE}" LANGUAGES CXX)

if(UNIX)
 include(GNUInstallDirs)
endif(UNIX)

set(HEADERS
  sources/generic/loadings/makeTextTextures.h
  sources/levels/contexts/demoLevel.h
  #This is a comment
  #Other files there
)

set(SOURCES
  sources/generic/loadings/makeTextTextures.cpp
  sources/levels/contexts/level.cpp
  #This is a comment
  #Other files there
)

add_executable( ${PROJECT_NAME}
    WIN32
    ${SOURCES}
    ${HEADERS}
    ${INC_DIRS}
)

target_include_directories(${PROJECT_NAME}
        PUBLIC ${SDL2_INCLUDE_DIRS}
        PUBLIC ${SDL2_IMAGE_INCLUDE_DIRS}
        PUBLIC ${SDL2_TTF_INCLUDE_DIRS}
        PUBLIC ${SDL2_MIXER_INCLUDE_DIRS}
        PUBLIC sources
        PUBLIC ../commonFiles/sources
        PUBLIC ../generic/sources
        PUBLIC ../inGame/sources
)

target_link_libraries( ${PROJECT_NAME}
      ${SDL2_LIBRARIES}
      ${SDL2_IMAGE_LIBRARIES}
      ${SDL2_TTF_LIBRARIES}
      ${SDL2_MIXER_LIBRARIES}
      "mercenaries_common_${SQUARE_SIZE}"
      "mercenaries_generic_${SQUARE_SIZE}"
      "mercenaries_inGame_${SQUARE_SIZE}"
)

set_target_properties( ${PROJECT_NAME}
      PROPERTIES
      CXX_STANDARD 20
      CXX_STANDARD_REQUIRED YES
      CXX_EXTENSIONS ON
      LINKER_LANGUAGE CXX
)

if( UNIX )
 math(EXPR SCREENWIDTH "${SQUARE_SIZE} * 20" OUTPUT_FORMAT DECIMAL )
 install(TARGETS ${PROJECT_NAME}
  RUNTIME DESTINATION
"/media/antoine/projetsLinux/final/MercenariesProject/Mercenaries${SCREENWIDTH}"
 )
endif(UNIX)

//-----------------End of CMakeLists.txt file
If you wonder what '${SQUARE_SIZE}' stands for, this is the logical size of a
tile in my game. In fact I use a combination of bash script files and povray to
make all textures in my game according to a given size of Tiles textures (the
size is passed to every shell scripts that compute the final size of the povray
image size that renders). Only one script to run and then some hours later, all
the textures I want are created. All I have to do then is to compile the
binaries with the same tile size that I give while running 'cmake' in command
line later.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.