Skip to content

Commit

Permalink
build inside qcorelib source folder
Browse files Browse the repository at this point in the history
  • Loading branch information
felixf4xu committed Jan 16, 2024
1 parent f386082 commit 30eaedd
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 20 deletions.
37 changes: 26 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
cmake_minimum_required(VERSION 3.0.0)
project(mcc VERSION 0.1.0 LANGUAGES C CXX)
project(qmetacc VERSION 0.1.0 LANGUAGES C CXX)

set(CMAKE_CXX_STANDARD 20)
add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/MP>)

add_executable(mcc main.cpp
add_executable(${PROJECT_NAME} main.cpp
collectjson.cpp
generator.cpp
moc.cpp
Expand All @@ -16,15 +16,30 @@ target_compile_definitions(${PROJECT_NAME} PUBLIC
UNICODE
)

find_package(QMetaClass REQUIRED)
target_link_libraries(${PROJECT_NAME} QMetaClass::QMetaClass)
get_target_property(QMetaClass_LIBRARY_DLL QMetaClass::QMetaClass LOCATION)
message(STATUS "Path to the library's DLL file: ${QMetaClass_LIBRARY_DLL}")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${QMetaClass_LIBRARY_DLL}
$<TARGET_FILE_DIR:mcc>
)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../qobject")
message(STATUS "Building with qcorelib source code: " "${CMAKE_CURRENT_SOURCE_DIR}/../qobject")
#build with qcorelib source code
target_link_libraries(${PROJECT_NAME} qcorelib)

#output the bin to be same as the library of qcorelib, easier to debug shared/dll library
set_target_properties( ${PROJECT_NAME}
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/"
)
else()
#build with installed qcorelib
find_package(QMetaClass REQUIRED)
target_link_libraries(${PROJECT_NAME} QMetaClass::QMetaClass)
get_target_property(QMetaClass_LIBRARY_DLL QMetaClass::QMetaClass LOCATION)
message(STATUS "Path to the library's DLL file: ${QMetaClass_LIBRARY_DLL}")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${QMetaClass_LIBRARY_DLL}
$<TARGET_FILE_DIR:${PROJECT_NAME}>
)
endif()

target_include_directories(${PROJECT_NAME} #private header files
PRIVATE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/>"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# mcc
# qmetacc
Meta Class Compiler, a modified version of Qt's Meta-Object Compiler (moc)


Expand Down
5 changes: 1 addition & 4 deletions generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "utils.h"
#include <qobject/qmetatype.h>
#include <qobject/qmetaobject.h>
// #include <qobject/qmetaobject_p.h>
#include <qobject/qmetamethod.h> //enum PropertyFlags

#include <serialization/qjsondocument.h>
#include <serialization/qjsonobject.h>
Expand All @@ -21,9 +21,6 @@
#include <math.h>
#include <stdio.h>

// #include <private/qmetaobject_p.h> //for the flags.
#include <plugin/qplugin.h> //for the flags.

QT_BEGIN_NAMESPACE

uint nameToBuiltinType(const QByteArray &name)
Expand Down
10 changes: 6 additions & 4 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#include <depfile_shared.h>
#include "preprocessor.h"
#include "moc.h"
#include "outputrevision.h"
#include "collectjson.h"

#include <io/qfile.h>
#include <io/qfileinfo.h>
Expand All @@ -21,6 +17,12 @@
#include <tools/qcommandlineparser.h>
#include <tools/qscopedpointer.h>

#include "preprocessor.h"
#include "moc.h"
#include "outputrevision.h"
#include "collectjson.h"
#include "token.h"

QT_BEGIN_NAMESPACE

using namespace Qt::StringLiterals;
Expand Down
7 changes: 7 additions & 0 deletions token.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@

QT_BEGIN_NAMESPACE

//windows, visual c++
#if defined(_MSC_VER) && !defined(__INTEL_COMPILER)
#ifdef PRIVATE
#undef PRIVATE
#endif
#endif

#define FOR_ALL_TOKENS(F) \
F(NOTOKEN) \
F(IDENTIFIER) \
Expand Down

0 comments on commit 30eaedd

Please sign in to comment.