From 94f8330613877b3582d32bd11abd83a97b4399ad Mon Sep 17 00:00:00 2001 From: Li Jin Date: Tue, 15 Nov 2022 17:23:46 +0800 Subject: adding -w option to Yuescript tool. --- CMakeLists.txt | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 105 insertions(+), 3 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 031af18..7532f81 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,14 +31,116 @@ enable_language(CXX) include_directories(src src/3rdParty ${LUA_INCLUDE_DIR}) add_definitions(-std=c++17 -O3 -fPIC) -add_library(libyue MODULE src/yuescript/ast.cpp src/yuescript/parser.cpp src/yuescript/yue_parser.cpp src/yuescript/yue_compiler.cpp src/yuescript/yuescript.cpp) +add_library(libyue MODULE + src/yuescript/ast.cpp + src/yuescript/parser.cpp + src/yuescript/yue_parser.cpp + src/yuescript/yue_compiler.cpp + src/yuescript/yuescript.cpp +) set_target_properties(libyue PROPERTIES PREFIX "") set_target_properties(libyue PROPERTIES OUTPUT_NAME "yue") target_link_libraries(libyue ${LUA_LIBRARIES}) +add_executable(yue + src/yuescript/ast.cpp + src/yuescript/yue_compiler.cpp + src/yuescript/yue_parser.cpp + src/yuescript/yuescript.cpp + src/yuescript/parser.cpp + src/yue.cpp +) + +target_sources(yue PRIVATE + src/3rdParty/efsw/Debug.cpp + src/3rdParty/efsw/DirectorySnapshot.cpp + src/3rdParty/efsw/DirectorySnapshotDiff.cpp + src/3rdParty/efsw/DirWatcherGeneric.cpp + src/3rdParty/efsw/FileInfo.cpp + src/3rdParty/efsw/FileSystem.cpp + src/3rdParty/efsw/FileWatcher.cpp + src/3rdParty/efsw/FileWatcherCWrapper.cpp + src/3rdParty/efsw/FileWatcherGeneric.cpp + src/3rdParty/efsw/FileWatcherImpl.cpp + src/3rdParty/efsw/Log.cpp + src/3rdParty/efsw/Mutex.cpp + src/3rdParty/efsw/String.cpp + src/3rdParty/efsw/System.cpp + src/3rdParty/efsw/Thread.cpp + src/3rdParty/efsw/Watcher.cpp + src/3rdParty/efsw/WatcherGeneric.cpp +) + +if (WIN32) + target_sources(yue PRIVATE + src/3rdParty/efsw/platform/win/FileSystemImpl.cpp + src/3rdParty/efsw/platform/win/MutexImpl.cpp + src/3rdParty/efsw/platform/win/SystemImpl.cpp + src/3rdParty/efsw/platform/win/ThreadImpl.cpp + ) +else () + target_sources(yue PRIVATE + src/3rdParty/efsw/platform/posix/FileSystemImpl.cpp + src/3rdParty/efsw/platform/posix/MutexImpl.cpp + src/3rdParty/efsw/platform/posix/SystemImpl.cpp + src/3rdParty/efsw/platform/posix/ThreadImpl.cpp + ) +endif() + +if (APPLE) + target_sources(yue PRIVATE + src/3rdParty/efsw/FileWatcherFSEvents.cpp + src/3rdParty/efsw/FileWatcherKqueue.cpp + src/3rdParty/efsw/WatcherFSEvents.cpp + src/3rdParty/efsw/WatcherKqueue.cpp + ) + + if (NOT CMAKE_SYSTEM_VERSION GREATER 9) + target_compile_definitions(yue PRIVATE EFSW_FSEVENTS_NOT_SUPPORTED) + endif() +elseif (WIN32) + target_sources(yue PRIVATE + src/3rdParty/efsw/FileWatcherWin32.cpp + src/3rdParty/efsw/WatcherWin32.cpp + ) +elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") + target_sources(yue PRIVATE + src/3rdParty/efsw/FileWatcherInotify.cpp + src/3rdParty/efsw/WatcherInotify.cpp + ) + + if (NOT EXISTS "/usr/include/sys/inotify.h" AND NOT EXISTS "/usr/local/include/sys/inotify.h") + target_compile_definitions(yue PRIVATE EFSW_INOTIFY_NOSYS) + endif() +elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") + target_sources(yue PRIVATE + src/3rdParty/efsw/FileWatcherKqueue.cpp + src/3rdParty/efsw/WatcherKqueue.cpp + ) +endif() + +if (MSVC) + target_compile_definitions(yue PRIVATE _SCL_SECURE_NO_WARNINGS) +else () + target_compile_options(yue PRIVATE -Wall -Wno-long-long -fPIC) +endif() + +if (${CMAKE_BUILD_TYPE} MATCHES "Debug") + target_compile_definitions(yue PRIVATE DEBUG) +elseif (${CMAKE_BUILD_TYPE} MATCHES "Release") + target_compile_definitions(yue PRIVATE NDEBUG) +endif() + find_package(Threads REQUIRED) -add_executable(yue src/yuescript/ast.cpp src/yuescript/yue_compiler.cpp src/yuescript/yue_parser.cpp src/yuescript/yuescript.cpp src/yuescript/parser.cpp src/yue.cpp) -target_link_libraries(yue ${LUA_LIBRARIES} Threads::Threads) +if (APPLE) + set(MAC_LIBS "-framework CoreFoundation" "-framework CoreServices") + target_link_libraries(yue PRIVATE ${LUA_LIBRARIES} ${MAC_LIBS} Threads::Threads) +elseif (NOT (${CMAKE_SYSTEM_NAME} MATCHES "Haiku") AND NOT WIN32) + target_link_libraries(yue PRIVATE ${LUA_LIBRARIES} Threads::Threads) +else () + target_link_libraries(yue PRIVATE ${LUA_LIBRARIES}) +endif() + IF(CMAKE_DL_LIBS) target_link_libraries(yue ${CMAKE_DL_LIBS}) ENDIF(CMAKE_DL_LIBS) -- cgit v1.2.3-55-g6feb