hedgewars/CMakeLists.txt
author Wuzzy <Wuzzy2@mail.ru>
Sun, 19 Jul 2020 22:08:55 +0200
changeset 15752 680dc787408c
parent 15577 107170c05bac
child 15872 b27bac2260e3
permissions -rw-r--r--
AI: Add new sine gun test (still WIP)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9677
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents: 9668
diff changeset
     1
enable_language(Pascal)
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents: 9668
diff changeset
     2
15577
107170c05bac Add patch to correctly handle libsdl2 from system/cmake
LocutusOfBorg
parents: 15370
diff changeset
     3
find_package(SDL2 REQUIRED CONFIG)
12383
e3d9abcc427a cmake: Fix SDL2 header version detection
sheepluva
parents: 11646
diff changeset
     4
find_package(SDL2_image 2 REQUIRED)
e3d9abcc427a cmake: Fix SDL2 header version detection
sheepluva
parents: 11646
diff changeset
     5
find_package(SDL2_net 2 REQUIRED)
e3d9abcc427a cmake: Fix SDL2 header version detection
sheepluva
parents: 11646
diff changeset
     6
find_package(SDL2_ttf 2 REQUIRED)
e3d9abcc427a cmake: Fix SDL2 header version detection
sheepluva
parents: 11646
diff changeset
     7
find_package(SDL2_mixer 2 REQUIRED)
2401
2a694ea2a437 fixes & co.
koda
parents: 2326
diff changeset
     8
9894
b7ef8bdaf5d7 This is the way I like it:
unc0rr
parents: 9886
diff changeset
     9
include(CheckLibraryExists)
b7ef8bdaf5d7 This is the way I like it:
unc0rr
parents: 9886
diff changeset
    10
include(${CMAKE_MODULE_PATH}/utils.cmake)
9224
bce8cf41d666 merge cmake_pascal branch in default
koda
parents: 9208 8863
diff changeset
    11
2672
0f1403bf267a check for sdl_image and sdl_mixer versions
koda
parents: 2671
diff changeset
    12
8752
48cf2ccb83c6 with lot of hackery, use add_executable on pascal files, SUCCSS
koda
parents: 8702
diff changeset
    13
enable_language(Pascal)
11646
42d7f5dbd8dc Fixes crash Wuzzy and I were encountering in debian fpc 2.6.2 and 3.0.0 after the addition of the uPhysFSLayer dependency to uUtils in rcac74d9075be
nemo
parents: 11392
diff changeset
    14
add_flag_append(CMAKE_Pascal_FLAGS "-Cs2000000 -B")
15338
e550096c2322 Remove accidental DEBUG flag in Pascal builds
Wuzzy <Wuzzy2@mail.ru>
parents: 15337
diff changeset
    15
add_flag_append(CMAKE_Pascal_FLAGS_DEBUG "-gv")
9886
af0520a6bf00 switch every optimization from Os to O2
koda
parents: 9883
diff changeset
    16
add_flag_append(CMAKE_Pascal_FLAGS_RELEASE "-Xs")
9921
7227cc2acba1 Fixed fPIC link failure with arm and sparc architectures, fixing issue #757
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents: 9894
diff changeset
    17
if(UNIX)
7227cc2acba1 Fixed fPIC link failure with arm and sparc architectures, fixing issue #757
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents: 9894
diff changeset
    18
    include(TargetArch)
7227cc2acba1 Fixed fPIC link failure with arm and sparc architectures, fixing issue #757
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents: 9894
diff changeset
    19
    target_architecture(CMAKE_TARGET_ARCHITECTURES)
7227cc2acba1 Fixed fPIC link failure with arm and sparc architectures, fixing issue #757
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents: 9894
diff changeset
    20
    if(${CMAKE_Pascal_COMPILER_VERSION} VERSION_GREATER 2.7 OR ${CMAKE_TARGET_ARCHITECTURES} MATCHES "x86_64" OR ${CMAKE_TARGET_ARCHITECTURES} MATCHES "i386")
7227cc2acba1 Fixed fPIC link failure with arm and sparc architectures, fixing issue #757
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents: 9894
diff changeset
    21
        add_flag_append(CMAKE_Pascal_FLAGS "-fPIC")
7227cc2acba1 Fixed fPIC link failure with arm and sparc architectures, fixing issue #757
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents: 9894
diff changeset
    22
    endif()
7227cc2acba1 Fixed fPIC link failure with arm and sparc architectures, fixing issue #757
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents: 9894
diff changeset
    23
endif(UNIX)
9883
d6d3be73d427 move CMAKE_Pascal_FLAGS_* flags after enabling the Pascal language or they get overwritten
koda
parents: 9743
diff changeset
    24
9996
d93fb04619ee unCORr likes PChar arrays
sheepluva
parents: 9991
diff changeset
    25
# convert list into pascal array
10747
07ade56c3b4a backporting some build system fixes and pas2c tweaks
sheepluva
parents: 10238
diff changeset
    26
if(FONTS_DIRS)
07ade56c3b4a backporting some build system fixes and pas2c tweaks
sheepluva
parents: 10238
diff changeset
    27
  list(LENGTH FONTS_DIRS ndirs)
07ade56c3b4a backporting some build system fixes and pas2c tweaks
sheepluva
parents: 10238
diff changeset
    28
  set(FONTS_DIRS_ARRAY "array [0..${ndirs}] of PChar = (")
07ade56c3b4a backporting some build system fixes and pas2c tweaks
sheepluva
parents: 10238
diff changeset
    29
  foreach(fontdir ${FONTS_DIRS})
07ade56c3b4a backporting some build system fixes and pas2c tweaks
sheepluva
parents: 10238
diff changeset
    30
      set(FONTS_DIRS_ARRAY "${FONTS_DIRS_ARRAY}\n_P'${fontdir}',")
07ade56c3b4a backporting some build system fixes and pas2c tweaks
sheepluva
parents: 10238
diff changeset
    31
  endforeach(fontdir)
07ade56c3b4a backporting some build system fixes and pas2c tweaks
sheepluva
parents: 10238
diff changeset
    32
  set(FONTS_DIRS_ARRAY "${FONTS_DIRS_ARRAY}\nnil);\n")
07ade56c3b4a backporting some build system fixes and pas2c tweaks
sheepluva
parents: 10238
diff changeset
    33
else(FONTS_DIRS)
07ade56c3b4a backporting some build system fixes and pas2c tweaks
sheepluva
parents: 10238
diff changeset
    34
  set(FONTS_DIRS_ARRAY "array [0..1] of PChar = (nil, nil);")
07ade56c3b4a backporting some build system fixes and pas2c tweaks
sheepluva
parents: 10238
diff changeset
    35
endif(FONTS_DIRS)
9224
bce8cf41d666 merge cmake_pascal branch in default
koda
parents: 9208 8863
diff changeset
    36
8702
a28966180a29 have fpc work in the right directory instead of passing the full path of the main module (avoids having full paths in debug build backtraces for the first module only)
koda
parents: 8697
diff changeset
    37
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.inc.in ${CMAKE_CURRENT_BINARY_DIR}/config.inc)
8846
c156ac6ddc2b set directories to be included externally, in the project file
koda
parents: 8843
diff changeset
    38
include_directories(${CMAKE_CURRENT_BINARY_DIR})
8661
ac8dba27a3f1 replace sdl mixer/image version checking with something more robust
koda
parents: 8611
diff changeset
    39
2672
0f1403bf267a check for sdl_image and sdl_mixer versions
koda
parents: 2671
diff changeset
    40
9299
d64f80504749 if you don't add the new pas files here they won't potentially trigger a rebuild anyway
koda
parents: 9285
diff changeset
    41
#set the sources with the correct order of dependencies so that cmake won't be confused
2786
85f6425a4d74 Engine:
smxx
parents: 2673
diff changeset
    42
set(engine_sources
8761
801cf78707f2 partial reodering of units so that dependency tracking is done with cmake
koda
parents: 8756
diff changeset
    43
    SDLh.pas
801cf78707f2 partial reodering of units so that dependency tracking is done with cmake
koda
parents: 8756
diff changeset
    44
    uSinTable.pas
801cf78707f2 partial reodering of units so that dependency tracking is done with cmake
koda
parents: 8756
diff changeset
    45
    uFloat.pas
801cf78707f2 partial reodering of units so that dependency tracking is done with cmake
koda
parents: 8756
diff changeset
    46
    uConsts.pas
7730
2013733f9ca9 A bit more on the knife. Also add missing files to CMakeLists
nemo
parents: 7718
diff changeset
    47
    LuaPas.pas
8761
801cf78707f2 partial reodering of units so that dependency tracking is done with cmake
koda
parents: 8756
diff changeset
    48
    uTypes.pas
9300
e5dafb5843c6 uvariables comes before uutils
koda
parents: 9299
diff changeset
    49
    uVariables.pas
8761
801cf78707f2 partial reodering of units so that dependency tracking is done with cmake
koda
parents: 8756
diff changeset
    50
    uUtils.pas
801cf78707f2 partial reodering of units so that dependency tracking is done with cmake
koda
parents: 8756
diff changeset
    51
    uMisc.pas
801cf78707f2 partial reodering of units so that dependency tracking is done with cmake
koda
parents: 8756
diff changeset
    52
    uConsole.pas
9301
c5d1c8259ef4 break uDebug and uCommand depedency loop by putting stuff in uIO
koda
parents: 9300
diff changeset
    53
    uCommands.pas
8761
801cf78707f2 partial reodering of units so that dependency tracking is done with cmake
koda
parents: 8756
diff changeset
    54
    uDebug.pas
14865
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 13943
diff changeset
    55
    uKeyNames.pas
8761
801cf78707f2 partial reodering of units so that dependency tracking is done with cmake
koda
parents: 8756
diff changeset
    56
    uInputHandler.pas
801cf78707f2 partial reodering of units so that dependency tracking is done with cmake
koda
parents: 8756
diff changeset
    57
    uTextures.pas
801cf78707f2 partial reodering of units so that dependency tracking is done with cmake
koda
parents: 8756
diff changeset
    58
    uRenderUtils.pas
801cf78707f2 partial reodering of units so that dependency tracking is done with cmake
koda
parents: 8756
diff changeset
    59
    uRender.pas
801cf78707f2 partial reodering of units so that dependency tracking is done with cmake
koda
parents: 8756
diff changeset
    60
    uCaptions.pas
801cf78707f2 partial reodering of units so that dependency tracking is done with cmake
koda
parents: 8756
diff changeset
    61
    uIO.pas
801cf78707f2 partial reodering of units so that dependency tracking is done with cmake
koda
parents: 8756
diff changeset
    62
    uChat.pas
801cf78707f2 partial reodering of units so that dependency tracking is done with cmake
koda
parents: 8756
diff changeset
    63
    uPhysFSLayer.pas
801cf78707f2 partial reodering of units so that dependency tracking is done with cmake
koda
parents: 8756
diff changeset
    64
    uSound.pas
9299
d64f80504749 if you don't add the new pas files here they won't potentially trigger a rebuild anyway
koda
parents: 9285
diff changeset
    65
    ArgParsers.pas
8761
801cf78707f2 partial reodering of units so that dependency tracking is done with cmake
koda
parents: 8756
diff changeset
    66
    uRandom.pas
801cf78707f2 partial reodering of units so that dependency tracking is done with cmake
koda
parents: 8756
diff changeset
    67
    uLocale.pas
801cf78707f2 partial reodering of units so that dependency tracking is done with cmake
koda
parents: 8756
diff changeset
    68
    uStats.pas
801cf78707f2 partial reodering of units so that dependency tracking is done with cmake
koda
parents: 8756
diff changeset
    69
    uCursor.pas
801cf78707f2 partial reodering of units so that dependency tracking is done with cmake
koda
parents: 8756
diff changeset
    70
    uVideoRec.pas
7730
2013733f9ca9 A bit more on the knife. Also add missing files to CMakeLists
nemo
parents: 7718
diff changeset
    71
    uAILandMarks.pas
8761
801cf78707f2 partial reodering of units so that dependency tracking is done with cmake
koda
parents: 8756
diff changeset
    72
    adler32.pas
801cf78707f2 partial reodering of units so that dependency tracking is done with cmake
koda
parents: 8756
diff changeset
    73
    uLandTemplates.pas
9302
1cf37fd7bc47 minor dep order change
koda
parents: 9301
diff changeset
    74
    uLandTexture.pas
8761
801cf78707f2 partial reodering of units so that dependency tracking is done with cmake
koda
parents: 8756
diff changeset
    75
    uLandGraphics.pas
801cf78707f2 partial reodering of units so that dependency tracking is done with cmake
koda
parents: 8756
diff changeset
    76
    uLandPainted.pas
801cf78707f2 partial reodering of units so that dependency tracking is done with cmake
koda
parents: 8756
diff changeset
    77
    uLandOutline.pas
801cf78707f2 partial reodering of units so that dependency tracking is done with cmake
koda
parents: 8756
diff changeset
    78
    uLandGenMaze.pas
10181
4708343d5963 Perlin noise generator untweaked, temporarily replacing maze generator
unc0rr
parents: 10174
diff changeset
    79
    uLandGenPerlin.pas
10198
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents: 10181
diff changeset
    80
    uLandGenTemplateBased.pas
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents: 10181
diff changeset
    81
    uLandUtils.pas
9302
1cf37fd7bc47 minor dep order change
koda
parents: 9301
diff changeset
    82
1cf37fd7bc47 minor dep order change
koda
parents: 9301
diff changeset
    83
    #this is where dependency tracking becomes hard
1cf37fd7bc47 minor dep order change
koda
parents: 9301
diff changeset
    84
    uStore.pas
1cf37fd7bc47 minor dep order change
koda
parents: 9301
diff changeset
    85
    uAmmos.pas
8761
801cf78707f2 partial reodering of units so that dependency tracking is done with cmake
koda
parents: 8756
diff changeset
    86
    uLandObjects.pas
801cf78707f2 partial reodering of units so that dependency tracking is done with cmake
koda
parents: 8756
diff changeset
    87
    uLand.pas
9302
1cf37fd7bc47 minor dep order change
koda
parents: 9301
diff changeset
    88
    uGearsList.pas
1cf37fd7bc47 minor dep order change
koda
parents: 9301
diff changeset
    89
    uCollisions.pas
8819
8e25b820b360 below this i cannot break the loop
koda
parents: 8813
diff changeset
    90
    uAIMisc.pas
8e25b820b360 below this i cannot break the loop
koda
parents: 8813
diff changeset
    91
    uAIActions.pas
9302
1cf37fd7bc47 minor dep order change
koda
parents: 9301
diff changeset
    92
    uAIAmmoTests.pas
8819
8e25b820b360 below this i cannot break the loop
koda
parents: 8813
diff changeset
    93
    uAI.pas
8e25b820b360 below this i cannot break the loop
koda
parents: 8813
diff changeset
    94
    uWorld.pas
9299
d64f80504749 if you don't add the new pas files here they won't potentially trigger a rebuild anyway
koda
parents: 9285
diff changeset
    95
    uVisualGearsList.pas
d64f80504749 if you don't add the new pas files here they won't potentially trigger a rebuild anyway
koda
parents: 9285
diff changeset
    96
    uVisualGearsHandlers.pas
8819
8e25b820b360 below this i cannot break the loop
koda
parents: 8813
diff changeset
    97
    uVisualGears.pas
8761
801cf78707f2 partial reodering of units so that dependency tracking is done with cmake
koda
parents: 8756
diff changeset
    98
801cf78707f2 partial reodering of units so that dependency tracking is done with cmake
koda
parents: 8756
diff changeset
    99
    uGears.pas
801cf78707f2 partial reodering of units so that dependency tracking is done with cmake
koda
parents: 8756
diff changeset
   100
    uGame.pas
4413
46caab3a8f84 uCommandHandlers
unc0rr
parents: 4403
diff changeset
   101
    uCommandHandlers.pas
9299
d64f80504749 if you don't add the new pas files here they won't potentially trigger a rebuild anyway
koda
parents: 9285
diff changeset
   102
    uGearsRender.pas
d64f80504749 if you don't add the new pas files here they won't potentially trigger a rebuild anyway
koda
parents: 9285
diff changeset
   103
    uGearsHedgehog.pas
7370
d50b874e7ee8 Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents: 7233
diff changeset
   104
    uGearsHandlers.pas
7592
cf67e58313ea Move rope code to separate unit
unc0rr
parents: 7370
diff changeset
   105
    uGearsHandlersRope.pas
9299
d64f80504749 if you don't add the new pas files here they won't potentially trigger a rebuild anyway
koda
parents: 9285
diff changeset
   106
    uGearsHandlersMess.pas
7592
cf67e58313ea Move rope code to separate unit
unc0rr
parents: 7370
diff changeset
   107
    uGearsUtils.pas
9302
1cf37fd7bc47 minor dep order change
koda
parents: 9301
diff changeset
   108
    uTeams.pas
9299
d64f80504749 if you don't add the new pas files here they won't potentially trigger a rebuild anyway
koda
parents: 9285
diff changeset
   109
d64f80504749 if you don't add the new pas files here they won't potentially trigger a rebuild anyway
koda
parents: 9285
diff changeset
   110
    #these interact with everything, so compile last
4357
a1fcfc341a52 Introduce unit uTypes in order to remove some cyclic unit dependencies
unC0Rr
parents: 4158
diff changeset
   111
    uScript.pas
a1fcfc341a52 Introduce unit uTypes in order to remove some cyclic unit dependencies
unC0Rr
parents: 4158
diff changeset
   112
    )
220
d79eaeaf969d Fix hwengine target behaviour
unc0rr
parents: 196
diff changeset
   113
7959
644b757d20e6 Start work on physfs support in engine
unc0rr
parents: 7817
diff changeset
   114
9963
9e75dbffec81 drop extra spaces from a few CMakeLists.txt files
koda
parents: 9961
diff changeset
   115
if(${CMAKE_Pascal_COMPILER_VERSION} VERSION_LESS 2.2 OR # older versions are just ancient
9e75dbffec81 drop extra spaces from a few CMakeLists.txt files
koda
parents: 9961
diff changeset
   116
   (${CMAKE_Pascal_COMPILER_VERSION} VERSION_LESS 2.6 AND APPLE)) # because of 64bit and opengl bindings
8852
0576439ef859 add and use the integrated version check
koda
parents: 8846
diff changeset
   117
    message(FATAL_ERROR "Your FreePascal installation is too old (fpc ${CMAKE_Pascal_COMPILER_VERSION})!")
9965
7ced30acf533 fix a few uses of VERSION_* checks
koda
parents: 9963
diff changeset
   118
elseif(${CMAKE_Pascal_COMPILER_VERSION} VERSION_GREATER 2.4)
8802
ed984e06b435 enable fpc inlining only in release mode only if using fpc > 2.6
koda
parents: 8798
diff changeset
   119
    #enable INLINE only with a recent version of fpc
8821
e85ff6e298b5 adjust verbosity, move debug/release variables in the right section
koda
parents: 8819
diff changeset
   120
    add_flag_prepend(CMAKE_Pascal_FLAGS_RELEASE -Si)
8164
b12634f2e1b2 Move noexecstack flags to Freepascal module and refactor.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents: 8162
diff changeset
   121
endif()
476
a4e975f70b60 check for noexecstack linker compatibility (MacOS linker)
displacer
parents: 433
diff changeset
   122
9942
0562f28ccb7a set common pascal library search path once
koda
parents: 9921
diff changeset
   123
#generic folder where our libraries reside
0562f28ccb7a set common pascal library search path once
koda
parents: 9921
diff changeset
   124
add_flag_append(CMAKE_Pascal_FLAGS "-Fl${LIBRARY_OUTPUT_PATH}")
476
a4e975f70b60 check for noexecstack linker compatibility (MacOS linker)
displacer
parents: 433
diff changeset
   125
8090
38d9cc60b14c cleanup revision section, make hg launch tolerant to config errors, drop deprecated exec_prog for desktop configuration in favour of execute_process
koda
parents: 8087
diff changeset
   126
#DEPENDECIES AND EXECUTABLES SECTION
9961
c18c66d621e5 consistent cmake checks
koda
parents: 9959
diff changeset
   127
if(APPLE AND (NOT BUILD_ENGINE_LIBRARY))
10973
36b84888934c Move OSX SDL library configuration from SDLh to proper CMakeLists
koda
parents: 10803
diff changeset
   128
    #OpenGL deps
36b84888934c Move OSX SDL library configuration from SDLh to proper CMakeLists
koda
parents: 10803
diff changeset
   129
    add_flag_append(CMAKE_Pascal_FLAGS "-k-framework -kCocoa")
36b84888934c Move OSX SDL library configuration from SDLh to proper CMakeLists
koda
parents: 10803
diff changeset
   130
    add_flag_append(CMAKE_Pascal_FLAGS "-k-framework -kOpenGL")
36b84888934c Move OSX SDL library configuration from SDLh to proper CMakeLists
koda
parents: 10803
diff changeset
   131
36b84888934c Move OSX SDL library configuration from SDLh to proper CMakeLists
koda
parents: 10803
diff changeset
   132
    #set the correct library or framework style depending on the main SDL
15577
107170c05bac Add patch to correctly handle libsdl2 from system/cmake
LocutusOfBorg
parents: 15370
diff changeset
   133
    string(FIND "${SDL2_LIBRARIES}" "dylib" sdl_framework)
10973
36b84888934c Move OSX SDL library configuration from SDLh to proper CMakeLists
koda
parents: 10803
diff changeset
   134
    if(${sdl_framework} GREATER -1)
11377
ee86941e2ade cmake: Adjust linker lines with sdl2 names
koda
parents: 11362
diff changeset
   135
        add_flag_append(CMAKE_Pascal_FLAGS "-k-lsdl2 -k-lsdl2_image -k-lsdl2_mixer -k-lsdl2_ttf -k-lsdl2_net")
10973
36b84888934c Move OSX SDL library configuration from SDLh to proper CMakeLists
koda
parents: 10803
diff changeset
   136
    else()
11377
ee86941e2ade cmake: Adjust linker lines with sdl2 names
koda
parents: 11362
diff changeset
   137
        add_flag_append(CMAKE_Pascal_FLAGS "-k-framework -kSDL2 -k-framework -kSDL2_image -k-framework -kSDL2_mixer -k-framework -kSDL2_net -k-framework -kSDL2_net -k-framework -kSDL2_ttf")
10973
36b84888934c Move OSX SDL library configuration from SDLh to proper CMakeLists
koda
parents: 10803
diff changeset
   138
    endif()
9271
118cc5c1f677 move some osx only configuration code
koda
parents: 9268
diff changeset
   139
endif()
7112
38c5d56c4d6e rename a few internal cmake variables (for consistency and readability)
koda
parents: 7109
diff changeset
   140
9959
1a42d36f346a use mainstream project name
koda
parents: 9945
diff changeset
   141
if(LIBAV_FOUND)
8811
dcdfcddf37ee move avwraper compilation in its own folder
koda
parents: 8804
diff changeset
   142
    add_subdirectory(avwrapper)
8843
843a9a405542 gather all libs in a single list
koda
parents: 8840
diff changeset
   143
    list(APPEND HW_LINK_LIBS avwrapper)
8775
3cad01db0bae apply the new macro add_flag_* to set pascal flags, apply add_definitions where appropriate, small cleanup
koda
parents: 8770
diff changeset
   144
    add_definitions(-dUSE_VIDEO_RECORDING)
7538
2d6e69b392cb better cmake script
Stepan777 <stepik-777@mail.ru>
parents: 7534
diff changeset
   145
endif()
7112
38c5d56c4d6e rename a few internal cmake variables (for consistency and readability)
koda
parents: 7109
diff changeset
   146
15335
fe705efbfc52 remove direct libpng dependency on windows
alfadur
parents: 14865
diff changeset
   147
if(NOT WIN32)
fe705efbfc52 remove direct libpng dependency on windows
alfadur
parents: 14865
diff changeset
   148
    find_package_or_disable_msg(PNG NOPNG "Screenshots will be saved in BMP")
fe705efbfc52 remove direct libpng dependency on windows
alfadur
parents: 14865
diff changeset
   149
    if(PNG_FOUND)
fe705efbfc52 remove direct libpng dependency on windows
alfadur
parents: 14865
diff changeset
   150
        list(INSERT engine_sources 0 PNGh.pas)
fe705efbfc52 remove direct libpng dependency on windows
alfadur
parents: 14865
diff changeset
   151
        list(REMOVE_AT PNG_LIBRARIES 1) #removing the zlib library path
fe705efbfc52 remove direct libpng dependency on windows
alfadur
parents: 14865
diff changeset
   152
        get_filename_component(PNG_LIBRARY_DIR ${PNG_LIBRARIES} PATH)
fe705efbfc52 remove direct libpng dependency on windows
alfadur
parents: 14865
diff changeset
   153
        add_flag_append(CMAKE_Pascal_FLAGS "-k-L${PNG_LIBRARY_DIR} -Fl${PNG_LIBRARY_DIR}")
fe705efbfc52 remove direct libpng dependency on windows
alfadur
parents: 14865
diff changeset
   154
        add_definitions(-dPNG_SCREENSHOTS)
fe705efbfc52 remove direct libpng dependency on windows
alfadur
parents: 14865
diff changeset
   155
    endif()
7112
38c5d56c4d6e rename a few internal cmake variables (for consistency and readability)
koda
parents: 7109
diff changeset
   156
endif()
38c5d56c4d6e rename a few internal cmake variables (for consistency and readability)
koda
parents: 7109
diff changeset
   157
10008
b8b91c7e0da8 drop redundancies for lua and physfs
koda
parents: 10004
diff changeset
   158
if(LUA_SYSTEM)
9208
acb2492288e5 heavily rework lua discovery and linking, needs testing but it's more similar to what we do for other libraries now
koda
parents: 9203
diff changeset
   159
    get_filename_component(LUA_LIBRARY_DIR ${LUA_LIBRARY} PATH)
acb2492288e5 heavily rework lua discovery and linking, needs testing but it's more similar to what we do for other libraries now
koda
parents: 9203
diff changeset
   160
    get_filename_component(LUA_LIBRARY_NAME ${LUA_LIBRARY} NAME)
acb2492288e5 heavily rework lua discovery and linking, needs testing but it's more similar to what we do for other libraries now
koda
parents: 9203
diff changeset
   161
    #NAME_WE would strip the .1 (or .2) next to the ".so"
acb2492288e5 heavily rework lua discovery and linking, needs testing but it's more similar to what we do for other libraries now
koda
parents: 9203
diff changeset
   162
    string(REGEX REPLACE "${CMAKE_SHARED_LIBRARY_PREFIX}(.*)${CMAKE_SHARED_LIBRARY_SUFFIX}" "\\1" LUA_LIBRARY_NAME "${LUA_LIBRARY_NAME}")
9230
035cc97de6aa oops, forgot to set the path after all
koda
parents: 9227
diff changeset
   163
    add_flag_append(CMAKE_Pascal_FLAGS "-Fl${LUA_LIBRARY_DIR} -XLAlua=${LUA_LIBRARY_NAME}")
9227
c02e081ba481 this should resolve a few issues on clean builds
koda
parents: 9225
diff changeset
   164
else()
c02e081ba481 this should resolve a few issues on clean builds
koda
parents: 9225
diff changeset
   165
    add_definitions(-dLUA_INTERNAL)
c02e081ba481 this should resolve a few issues on clean builds
koda
parents: 9225
diff changeset
   166
    list(APPEND HW_LINK_LIBS lua)
c02e081ba481 this should resolve a few issues on clean builds
koda
parents: 9225
diff changeset
   167
    add_flag_append(CMAKE_Pascal_FLAGS "-XLAlua=${lua_output_name}")
9208
acb2492288e5 heavily rework lua discovery and linking, needs testing but it's more similar to what we do for other libraries now
koda
parents: 9203
diff changeset
   168
endif()
7655
b993257902d3 if this doesn't work I shall cry like a lady
sheepluva
parents: 7654
diff changeset
   169
13904
99b265e0d1d0 Drop internal PhysFS, bump PhysFS requirement to 3.0.0
Wuzzy <Wuzzy2@mail.ru>
parents: 12383
diff changeset
   170
# PhysFS
99b265e0d1d0 Drop internal PhysFS, bump PhysFS requirement to 3.0.0
Wuzzy <Wuzzy2@mail.ru>
parents: 12383
diff changeset
   171
get_filename_component(PHYSFS_LIBRARY_DIR ${PHYSFS_LIBRARY} PATH)
99b265e0d1d0 Drop internal PhysFS, bump PhysFS requirement to 3.0.0
Wuzzy <Wuzzy2@mail.ru>
parents: 12383
diff changeset
   172
add_flag_append(CMAKE_Pascal_FLAGS "-Fl${PHYSFS_LIBRARY}")
99b265e0d1d0 Drop internal PhysFS, bump PhysFS requirement to 3.0.0
Wuzzy <Wuzzy2@mail.ru>
parents: 12383
diff changeset
   173
8843
843a9a405542 gather all libs in a single list
koda
parents: 8840
diff changeset
   174
list(APPEND HW_LINK_LIBS physlayer)
7655
b993257902d3 if this doesn't work I shall cry like a lady
sheepluva
parents: 7654
diff changeset
   175
9942
0562f28ccb7a set common pascal library search path once
koda
parents: 9921
diff changeset
   176
10015
4feced261c68 partial merge of the webgl branch
koda
parents: 10008 9950
diff changeset
   177
#opengl 2
4feced261c68 partial merge of the webgl branch
koda
parents: 10008 9950
diff changeset
   178
IF(GL2)
4feced261c68 partial merge of the webgl branch
koda
parents: 10008 9950
diff changeset
   179
    add_definitions(-dGL2)
4feced261c68 partial merge of the webgl branch
koda
parents: 10008 9950
diff changeset
   180
ENDIF(GL2)
9650
1c7c87ce37fd add possibility to compile with SDL2 automatically
koda
parents: 9339
diff changeset
   181
9224
bce8cf41d666 merge cmake_pascal branch in default
koda
parents: 9208 8863
diff changeset
   182
#needs to be last
8775
3cad01db0bae apply the new macro add_flag_* to set pascal flags, apply add_definitions where appropriate, small cleanup
koda
parents: 8770
diff changeset
   183
add_definitions(-dDEBUGFILE)
9203
bcc25cb9b122 and now also avwrapper can be shared/static, add visibility to its exported functions, drop (needed only when static)
koda
parents: 9151
diff changeset
   184
9741
cf086f49516b make source files objects depend on their predecessors in list
sheepluva
parents: 9668
diff changeset
   185
9894
b7ef8bdaf5d7 This is the way I like it:
unc0rr
parents: 9886
diff changeset
   186
# source files are with full path after this
9743
6e505ea936ad make all objects depend on .inc files (which are not correctly positioned in list, because cmake can't deal with that
sheepluva
parents: 9741
diff changeset
   187
set(sourcefiles_sofar "${CMAKE_CURRENT_SOURCE_DIR}/options.inc" "${CMAKE_CURRENT_BINARY_DIR}/config.inc")
9741
cf086f49516b make source files objects depend on their predecessors in list
sheepluva
parents: 9668
diff changeset
   188
foreach(loop_var ${engine_sources})
cf086f49516b make source files objects depend on their predecessors in list
sheepluva
parents: 9668
diff changeset
   189
    list(APPEND sourcefiles_sofar "${CMAKE_CURRENT_SOURCE_DIR}/${loop_var}")
cf086f49516b make source files objects depend on their predecessors in list
sheepluva
parents: 9668
diff changeset
   190
endforeach(loop_var)
cf086f49516b make source files objects depend on their predecessors in list
sheepluva
parents: 9668
diff changeset
   191
13943
3a0d09a31f5f fix library names in engine
alfadur
parents: 13904
diff changeset
   192
if (WIN32 AND VCPKG_TOOLCHAIN)
3a0d09a31f5f fix library names in engine
alfadur
parents: 13904
diff changeset
   193
    add_definitions(-dWIN32_VCPKG)
15339
360c24fe6071 use different flag for vcpkg debug
alfadur
parents: 15338
diff changeset
   194
    add_flag_append(CMAKE_Pascal_FLAGS_DEBUG "-dVCPKG_DEBUG")
13943
3a0d09a31f5f fix library names in engine
alfadur
parents: 13904
diff changeset
   195
endif()
3a0d09a31f5f fix library names in engine
alfadur
parents: 13904
diff changeset
   196
15370
96254b857257 update windows build to detect when a cross-compiler is necessary
alfadur
parents: 15358
diff changeset
   197
if (WIN32_WIN64_CROSS_COMPILE)
96254b857257 update windows build to detect when a cross-compiler is necessary
alfadur
parents: 15358
diff changeset
   198
    add_flag_append(CMAKE_Pascal_FLAGS "-Px86_64 -Twin64")
96254b857257 update windows build to detect when a cross-compiler is necessary
alfadur
parents: 15358
diff changeset
   199
endif()
9741
cf086f49516b make source files objects depend on their predecessors in list
sheepluva
parents: 9668
diff changeset
   200
8823
65b430b6cd68 add support for creating shared pascal libraries
koda
parents: 8821
diff changeset
   201
#SOURCE AND PROGRAMS SECTION
65b430b6cd68 add support for creating shared pascal libraries
koda
parents: 8821
diff changeset
   202
if(BUILD_ENGINE_LIBRARY)
9339
14f5f3a1e2f7 some work on cmake_pascal files to better support flags we use, make engine compile as library again
koda
parents: 9302
diff changeset
   203
    message("***Engine will be built as library (experimental)***")
10160
4608f10ae65f - Make world wrap edges not depend on gear radius
unc0rr
parents: 10015
diff changeset
   204
    if(APPLE)
4608f10ae65f - Make world wrap edges not depend on gear radius
unc0rr
parents: 10015
diff changeset
   205
        if (${current_macosx_version} VERSION_GREATER "10.5")
4608f10ae65f - Make world wrap edges not depend on gear radius
unc0rr
parents: 10015
diff changeset
   206
            # due to compiler/linker issues on Max OS X 10.6 -k-no_order_inits is needed to avoid linking fail
4608f10ae65f - Make world wrap edges not depend on gear radius
unc0rr
parents: 10015
diff changeset
   207
            add_flag_prepend(CMAKE_Pascal_FLAGS "-k-no_order_inits")
4608f10ae65f - Make world wrap edges not depend on gear radius
unc0rr
parents: 10015
diff changeset
   208
        endif()
8823
65b430b6cd68 add support for creating shared pascal libraries
koda
parents: 8821
diff changeset
   209
    endif()
7954
a5f0a6d46c52 advice from hasufell
koda
parents: 7942
diff changeset
   210
8823
65b430b6cd68 add support for creating shared pascal libraries
koda
parents: 8821
diff changeset
   211
    #workaround for missing <TARGET> support during object generation
65b430b6cd68 add support for creating shared pascal libraries
koda
parents: 8821
diff changeset
   212
    set(engine_output_name "${CMAKE_SHARED_LIBRARY_PREFIX}hwengine${CMAKE_SHARED_LIBRARY_SUFFIX}")
65b430b6cd68 add support for creating shared pascal libraries
koda
parents: 8821
diff changeset
   213
    set(destination_dir ${target_library_install_dir})
8827
koda
parents: 8825
diff changeset
   214
    add_flag_prepend(CMAKE_Pascal_FLAGS "-o${LIBRARY_OUTPUT_PATH}/${engine_output_name}")
8823
65b430b6cd68 add support for creating shared pascal libraries
koda
parents: 8821
diff changeset
   215
65b430b6cd68 add support for creating shared pascal libraries
koda
parents: 8821
diff changeset
   216
    add_definitions(-dHWLIBRARY)
10174
710ffaae7d59 - Fix crasher in doStepSniperRifleShot
unc0rr
parents: 10168
diff changeset
   217
    set_source_files_properties(hwLibrary.pas PROPERTIES OBJECT_DEPENDS "${sourcefiles_sofar};${CMAKE_CURRENT_SOURCE_DIR}/hwengine.pas")
9894
b7ef8bdaf5d7 This is the way I like it:
unc0rr
parents: 9886
diff changeset
   218
    add_library(hwengine SHARED hwLibrary.pas)
8823
65b430b6cd68 add support for creating shared pascal libraries
koda
parents: 8821
diff changeset
   219
else()
15358
06e5f9ec5f8d Handle a possible linker error on macOS
raptor <buckyballreaction@gmail.com>
parents: 15339
diff changeset
   220
    if(APPLE)
06e5f9ec5f8d Handle a possible linker error on macOS
raptor <buckyballreaction@gmail.com>
parents: 15339
diff changeset
   221
        # Handle large linker install_names
06e5f9ec5f8d Handle a possible linker error on macOS
raptor <buckyballreaction@gmail.com>
parents: 15339
diff changeset
   222
        add_flag_prepend(CMAKE_Pascal_FLAGS "-k-headerpad_max_install_names")
06e5f9ec5f8d Handle a possible linker error on macOS
raptor <buckyballreaction@gmail.com>
parents: 15339
diff changeset
   223
    endif()
06e5f9ec5f8d Handle a possible linker error on macOS
raptor <buckyballreaction@gmail.com>
parents: 15339
diff changeset
   224
8823
65b430b6cd68 add support for creating shared pascal libraries
koda
parents: 8821
diff changeset
   225
    # no need to change name here because target has same name
65b430b6cd68 add support for creating shared pascal libraries
koda
parents: 8821
diff changeset
   226
    set(engine_output_name "hwengine${CMAKE_EXECUTABLE_SUFFIX}")
65b430b6cd68 add support for creating shared pascal libraries
koda
parents: 8821
diff changeset
   227
    set(destination_dir ${target_binary_install_dir})
9894
b7ef8bdaf5d7 This is the way I like it:
unc0rr
parents: 9886
diff changeset
   228
    set_source_files_properties(hwengine.pas PROPERTIES OBJECT_DEPENDS "${sourcefiles_sofar}")
b7ef8bdaf5d7 This is the way I like it:
unc0rr
parents: 9886
diff changeset
   229
    add_executable(hwengine hwengine.pas)
7538
2d6e69b392cb better cmake script
Stepan777 <stepik-777@mail.ru>
parents: 7534
diff changeset
   230
endif()
7112
38c5d56c4d6e rename a few internal cmake variables (for consistency and readability)
koda
parents: 7109
diff changeset
   231
8855
879270f627e0 restore the osx build disabling universal app support
koda
parents: 8852
diff changeset
   232
#even though not actually used, this will trigger relink if any lib changes
8843
843a9a405542 gather all libs in a single list
koda
parents: 8840
diff changeset
   233
target_link_libraries(hwengine ${HW_LINK_LIBS})
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
   234
8316
89232b2fa1d6 cmake rework, cleanup a lot of redundant sections, separate library and binary install location, unify osx and win handling of the data directory (tested on win, lin and mac)
koda
parents: 8314
diff changeset
   235
install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}" DESTINATION ${destination_dir})