1
0
mirror of https://github.com/g012/l65.git synced 2024-11-16 10:09:13 +00:00
l65/CMakeLists.txt

119 lines
3.7 KiB
CMake
Raw Normal View History

2017-09-26 23:33:21 +00:00
cmake_minimum_required(VERSION 3.1)
project(l65)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
set(L65_SOURCE_DIR ${PROJECT_SOURCE_DIR})
set(L65_BINARY_DIR ${PROJECT_BINARY_DIR})
set(L65_VERSION_MAJOR "1")
set(L65_VERSION_MINOR "2")
set(L65_VERSION_REVISION "2")
2017-09-26 23:33:21 +00:00
set(L65_VERSION "${L65_VERSION_MAJOR}.${L65_VERSION_MINOR}.${L65_VERSION_REVISION}")
configure_file("${L65_SOURCE_DIR}/l65cfg.lua.in" "${L65_BINARY_DIR}/l65cfg.lua")
set(LINKLIBS)
if (MSVC)
set(USE_MSVC_RUNTIME_LIBRARY_DLL OFF CACHE BOOL "" FORCE)
add_definitions(-D_HAS_EXCEPTIONS=0 -DWIN32_LEAN_AND_MEAN -DUNICODE -D_UNICODE)
add_definitions(-DNOMINMAX -D_USE_MATH_DEFINES)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS)
foreach (flag CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if (${flag} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")
endif()
if (${flag} MATCHES "/MDd")
string(REGEX REPLACE "/MDd" "/MTd" ${flag} "${${flag}}")
endif()
if(${flag} MATCHES "/EHsc")
string(REGEX REPLACE "/EHsc" "/EHs-c-" ${flag} "${${flag}}")
endif()
if(${flag} MATCHES "/GR")
string(REGEX REPLACE "/GR" "/GR-" ${flag} "${${flag}}")
endif()
if(${flag} MATCHES "/Gm")
string(REGEX REPLACE "/Gm" "/Gm-" ${flag} "${${flag}}")
endif()
endforeach()
add_compile_options(/WX /MP /fp:fast /volatile:iso)
add_compile_options(/wd4103 /wd4244 /wd4456 /wd4554 /wd4557 /wd4702 /wd6255 /wd6262 /wd28278)
else ()
if (APPLE)
add_definitions(-DLUA_USE_MACOSX)
else ()
add_definitions(-DLUA_USE_LINUX)
endif ()
add_definitions(-D_FILE_OFFSET_BITS=64)
2017-09-28 10:06:33 +00:00
add_compile_options(-fno-strict-aliasing -fomit-frame-pointer -ffast-math -fvisibility=hidden)
2017-10-04 22:12:28 +00:00
add_compile_options(-Wsign-compare -Wno-missing-braces -Wno-unused-result -Wno-unused-function -Wno-unused-variable -Wno-switch -Wno-parentheses)
2017-09-26 23:33:21 +00:00
endif()
set(L65_SOURCES
${L65_SOURCE_DIR}/lfs.c
${L65_SOURCE_DIR}/lpeg.c
${L65_SOURCE_DIR}/main.c
)
set(L65_HEADERS
${L65_SOURCE_DIR}/lua.h
${L65_BINARY_DIR}/scripts.h
2017-10-04 22:12:28 +00:00
${L65_SOURCE_DIR}/stb_image.h
2017-09-26 23:33:21 +00:00
)
file(GLOB L65_FILES ${L65_SOURCE_DIR}/*.l65)
set(L65_SCRIPTS
${L65_SOURCE_DIR}/6502.lua
${L65_SOURCE_DIR}/dkjson.lua
${L65_SOURCE_DIR}/l65.lua
${L65_BINARY_DIR}/l65cfg.lua
${L65_SOURCE_DIR}/re.lua
${L65_FILES}
)
2017-09-28 09:10:25 +00:00
add_executable(embed ${L65_SOURCE_DIR}/embed.c)
2017-09-28 10:06:33 +00:00
set_property(TARGET embed PROPERTY C_STANDARD 99)
2017-09-26 23:33:21 +00:00
add_custom_command(
OUTPUT ${L65_BINARY_DIR}/scripts.h
COMMAND embed -o ${L65_BINARY_DIR}/scripts.h ${L65_SCRIPTS}
DEPENDS embed ${L65_SCRIPTS}
2017-09-26 23:33:21 +00:00
)
add_custom_target(prereq DEPENDS ${L65_BINARY_DIR}/scripts.h)
add_executable(${PROJECT_NAME} ${L65_SOURCES} ${L65_HEADERS} ${L65_FILES})
add_dependencies(${PROJECT_NAME} prereq)
2017-09-26 23:33:21 +00:00
set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 99)
target_include_directories(${PROJECT_NAME} PRIVATE "${L65_SOURCE_DIR}" "${L65_BINARY_DIR}")
if (MSVC)
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/INCREMENTAL:NO /MANIFEST:NO /SUBSYSTEM:CONSOLE /ENTRY:mainCRTStartup")
elseif (UNIX)
list(APPEND LINKLIBS m)
if (NOT APPLE)
list(APPEND LINKLIBS dl)
endif()
2017-09-26 23:33:21 +00:00
endif()
2017-09-28 10:06:33 +00:00
target_link_libraries(embed ${LINKLIBS})
2017-09-26 23:33:21 +00:00
target_link_libraries(${PROJECT_NAME} ${LINKLIBS})