CMake files now better resemble the genie scripts of MAME

Might now compile on Windows, freebsd and macOS?
This commit is contained in:
CharlesThobe 2022-01-05 03:49:20 +02:00
parent e8e1c21b65
commit f0db2ff486
8 changed files with 319 additions and 248 deletions

View File

@ -8,6 +8,30 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_CXX_STANDARD 17) #needed by libocore and libutils. -
#set globally to match MAME's genie scripts.
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
add_compile_definitions(
X64_WINDOWS_ABI
CRLF=3
)
else()
add_compile_definitions(
CRLF=2
)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wbad-function-cast")
endif()
function(addprojectflags)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsuggest-override -flifetime-dse=1")
endif()
endfunction()
add_subdirectory(cmake_subdirs)
#chdman
@ -15,6 +39,7 @@ add_executable(chdman
${CMAKE_SOURCE_DIR}/src/tools/chdman.cpp
${CMAKE_SOURCE_DIR}/src/version.cpp
)
target_include_directories(chdman PRIVATE
${CMAKE_SOURCE_DIR}/src/osd
${CMAKE_SOURCE_DIR}/src/lib/util
@ -27,8 +52,5 @@ BARE_BUILD_VERSION="${build_version}"
BARE_VCS_REVISION="${vcs_revision}"
)
#linking
#target_link_libraries(ocore_sdl PRIVATE SDL2)
target_link_libraries(chdman PRIVATE utils expat 7z ocore_sdl zlib flac utf8proc
dl rt m pthread util)

View File

@ -1,8 +1,19 @@
#lib7z
add_compile_definitions(_7ZIP_PPMD_SUPPPORT _7ZIP_ST)
set(CMAKE_C_FLAGS "-Wno-strict-prototypes -Wno-undef -Wno-misleading-indentation")
set(7z_dir ${CMAKE_SOURCE_DIR}/3rdparty/lzma)
if(CMAKE_GENERATOR STREQUAL "Unix Makefiles" OR CMAKE_GENERATOR STREQUAL "Ninja")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-strict-prototypes -Wno-undef")
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "Clang" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 10.0)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-misleading-indentation")
endif()
add_compile_definitions(
_7ZIP_PPMD_SUPPPORT
_7ZIP_ST
)
add_library(7z STATIC
${7z_dir}/C/7zAlloc.c
${7z_dir}/C/7zArcIn.c

View File

@ -1,5 +1,5 @@
#libexpat
option(BIGENDIAN OFF)
#option(BIGENDIAN OFF)
set(expat_dir ${CMAKE_SOURCE_DIR}/3rdparty/expat)
add_compile_definitions(
@ -20,15 +20,25 @@ XML_CONTEXT_BYTES=1024
XML_DTD
XML_NS
)
if(CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 11.1)
set(CMAKE_C_FLAGS "-Wno-maybe-uninitialized")
#if(BIGENDIAN)
#add_compile_definitions(
# BYTEORDER=4321
# WORDS_BIGENDIAN
#)
#else()
add_compile_definitions(
BYTEORDER=1234
)
#endif()
if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
add_compile_definitions(
HAVE_ARC4RANDOM
)
endif()
if(BIGENDIAN)
add_compile_definitions(BYTEORDER=4321 WORDS_BIGENDIAN)
else()
add_compile_definitions(BYTEORDER=1234)
endif()
#if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
add_compile_definitions(
HAVE_DLFCN_H
HAVE_FCNTL_H
@ -38,7 +48,7 @@ HAVE_SYS_TYPES_H
HAVE_UNISTD_H
XML_DEV_URANDOM
)
#endif()
endif()
add_library(expat STATIC
${expat_dir}/lib/xmlparse.c

View File

@ -11,13 +11,17 @@ HAVE_CONFIG_H=1
)
if(${CMAKE_GENERATOR} STREQUAL "Unix Makefiles" OR ${CMAKE_GENERATOR} STREQUAL "Ninja")
set(CMAKE_C_FLAGS "-Wno-unused-function -O0")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function -O0")
endif()
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") #fixme: or android
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-enum-conversion")
endif()
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unknown-attributes")
endif()
include_directories(
${flac_dir}/src/libFLAC/include
${flac_dir}/include

View File

@ -1,5 +1,4 @@
#ocore_sdl
set(CMAKE_CXX_STANDARD 17)
include_directories(
${CMAKE_SOURCE_DIR}/src/emu
${CMAKE_SOURCE_DIR}/src/osd
@ -18,13 +17,29 @@ ${CMAKE_SOURCE_DIR}/src/osd/osdsync.cpp
${CMAKE_SOURCE_DIR}/src/osd/osdsync.h
${CMAKE_SOURCE_DIR}/src/osd/modules/osdmodule.cpp
${CMAKE_SOURCE_DIR}/src/osd/modules/osdmodule.h
#${CMAKE_SOURCE_DIR}/src/osd/modules/lib/osdlib_unix.cpp
${CMAKE_SOURCE_DIR}/src/osd/modules/lib/osd_getenv.cpp
${CMAKE_SOURCE_DIR}/src/osd/modules/lib/osd_getenv.cpp #instead of osdlib_${target_os}.cpp
${CMAKE_SOURCE_DIR}/src/osd/modules/lib/osdlib.h
)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_sources(ocore_sdl PRIVATE
${CMAKE_SOURCE_DIR}/src/osd/modules/file/posixdir.cpp
${CMAKE_SOURCE_DIR}/src/osd/modules/file/posixfile.cpp
${CMAKE_SOURCE_DIR}/src/osd/modules/file/posixfile.h
${CMAKE_SOURCE_DIR}/src/osd/modules/file/posixptty.cpp
${CMAKE_SOURCE_DIR}/src/osd/modules/file/posixsocket.cpp
#${CMAKE_SOURCE_DIR}/src/osd/modules/file/stdfile.cpp
)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
target_sources(ocore_sdl PRIVATE
${CMAKE_SOURCE_DIR}/src/osd/modules/file/windir.cpp
${CMAKE_SOURCE_DIR}/src/osd/modules/file/winfile.cpp
${CMAKE_SOURCE_DIR}/src/osd/modules/file/winfile.h
${CMAKE_SOURCE_DIR}/src/osd/modules/file/winptty.cpp
${CMAKE_SOURCE_DIR}/src/osd/modules/file/winsocket.cpp
${CMAKE_SOURCE_DIR}/src/osd/windows/winutil.cpp
)
else()
target_sources(ocore_sdl PRIVATE
${CMAKE_SOURCE_DIR}/src/osd/modules/file/stdfile.cpp
)
endif()

View File

@ -1,8 +1,11 @@
#utf8proc
set(utf8proc_dir ${CMAKE_SOURCE_DIR}/3rdparty/utf8proc)
add_compile_definitions(UTF8PROC_STATIC)
add_compile_definitions(
UTF8PROC_STATIC
)
if(${CMAKE_GENERATOR} STREQUAL "Unix Makefiles" OR ${CMAKE_GENERATOR} STREQUAL "Ninja")
set(CMAKE_C_FLAGS "-Wno-strict-prototypes")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-strict-prototypes")
endif()
add_library(utf8proc STATIC

View File

@ -1,11 +1,7 @@
#utils
set(utils_dir ${CMAKE_SOURCE_DIR}/src/lib/util)
add_compile_definitions(UTF8PROC_STATIC)
set(CMAKE_CXX_STANDARD 17)
#if unix
add_compile_definitions(CRLF=2)
#endif()
addprojectflags()
include_directories(
${CMAKE_SOURCE_DIR}/src/osd
@ -17,6 +13,10 @@ ${CMAKE_SOURCE_DIR}/3rdparty/libflac/include
${CMAKE_SOURCE_DIR}/3rdparty/utf8proc
)
add_compile_definitions(
UTF8PROC_STATIC
)
add_library(utils STATIC
${utils_dir}/abi.h
${utils_dir}/avhuff.cpp

View File

@ -1,11 +1,17 @@
#zlib
set(zlib_dir ${CMAKE_SOURCE_DIR}/3rdparty/zlib)
set(CMAKE_C_FLAGS "-Wno-shift-negative-value")
if(CMAKE_C_COMPILER_ID STREQUAL "Clang") #fixme: or android
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-shift-negative-value")
endif()
if(${CMAKE_GENERATOR} STREQUAL "Unix Makefiles" OR ${CMAKE_GENERATOR} STREQUAL "Ninja")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-strict-prototypes")
endif()
add_compile_definitions(ZLIB_CONST)
add_compile_definitions(
ZLIB_CONST
)
add_library(zlib STATIC
${zlib_dir}/adler32.c