fix tcl/tk build flags

This commit is contained in:
Matthias Hochsteger 2022-05-05 18:04:18 +02:00
parent 66078cb285
commit 03347e8e33
3 changed files with 28 additions and 31 deletions

View File

@ -251,40 +251,47 @@ endif(USE_GUI)
target_link_libraries(nglib PUBLIC ${ZLIB_LIBRARIES})
#######################################################################
if(WIN32)
add_library(netgen_gui INTERFACE IMPORTED)
else()
add_library(netgen_gui INTERFACE)
endif()
if (USE_GUI)
find_package(TCL 8.5 REQUIRED)
find_package(TclStub 8.5 REQUIRED)
find_package(Threads REQUIRED)
if(APPLE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework AppKit")
target_link_libraries(nggui PUBLIC "-framework AppKit")
target_link_libraries(netgen_gui INTERFACE "-framework AppKit")
else(APPLE)
find_package(X11 REQUIRED)
target_link_libraries( nggui PUBLIC ${X11_Xmu_LIB} ${X11_X11_LIB})
target_link_libraries( netgen_gui INTERFACE ${X11_Xmu_LIB} ${X11_X11_LIB})
endif(APPLE)
find_package(OpenGL REQUIRED)
target_compile_definitions(nggui PUBLIC -DTCL -DOPENGL -DUSE_TOGL_2 PRIVATE -DUSE_TCL_STUBS -DUSE_TK_STUBS)
target_include_directories(nggui PRIVATE ${TCL_INCLUDE_PATH} ${TK_INCLUDE_PATH})
target_compile_definitions(netgen_gui INTERFACE -DTCL -DOPENGL -DUSE_TOGL_2 -DUSE_TCL_STUBS -DUSE_TK_STUBS)
target_include_directories(netgen_gui INTERFACE ${TCL_INCLUDE_PATH} ${TK_INCLUDE_PATH})
target_link_libraries(netgen_gui INTERFACE ${TCL_STUB_LIBRARY} ${TK_STUB_LIBRARY})
if(NOT EXISTS ${TK_INCLUDE_PATH}/tkWin.h AND EXISTS ${TK_INCLUDE_PATH}/../win/tkWin.h)
target_include_directories(nggui PRIVATE ${TK_INCLUDE_PATH}/../win)
target_include_directories(netgen_gui INTERFACE ${TK_INCLUDE_PATH}/../win)
endif()
if(NOT EXISTS ${TK_INCLUDE_PATH}/x11/Xlib.h AND EXISTS ${TK_INCLUDE_PATH}/../xlib/X11/Xlib.h)
target_include_directories(nggui PRIVATE ${TK_INCLUDE_PATH}/../xlib)
target_include_directories(netgen_gui INTERFACE ${TK_INCLUDE_PATH}/../xlib)
endif()
target_link_libraries(nggui PUBLIC nglib togl
PRIVATE "$<BUILD_INTERFACE:netgen_python>" )
target_link_libraries(nggui PUBLIC nglib togl PRIVATE "$<BUILD_INTERFACE:netgen_python>" )
if(WIN32)
target_compile_definitions(nggui PUBLIC -DTOGL_WGL)
else(WIN32)
if(APPLE)
target_compile_definitions(nggui PUBLIC -DTOGL_NSOPENGL)
else(APPLE)
target_compile_definitions(nggui PUBLIC -DTOGL_X11)
endif(APPLE)
endif(WIN32)
target_compile_definitions(netgen_gui INTERFACE -DTOGL_WGL)
endif()
if(APPLE)
target_compile_definitions(netgen_gui INTERFACE -DTOGL_NSOPENGL)
endif()
if(UNIX AND NOT APPLE)
target_compile_definitions(netgen_gui INTERFACE -DTOGL_X11)
endif()
endif (USE_GUI)
#######################################################################

View File

@ -23,13 +23,12 @@ if(USE_GUI)
if(WIN32)
target_sources(netgen PRIVATE ../windows/netgen.rc)
endif(WIN32)
target_link_libraries( netgen nglib nggui netgen_python ${TK_LIBRARY} ${TCL_LIBRARY})
target_include_directories(netgen PRIVATE ${TCL_INCLUDE_PATH} ${TK_INCLUDE_PATH})
target_link_libraries( netgen nglib nggui netgen_python netgen_gui)
install(TARGETS netgen ${NG_INSTALL_DIR})
if(APPLE)
set_target_properties(netgen PROPERTIES OUTPUT_NAME netgen)
endif(APPLE)
target_link_libraries( netgen ${PYTHON_LIBRARIES})
target_link_libraries( netgen ${PYTHON_LIBRARIES} ${TCL_LIBRARY} ${TK_LIBRARY})
endif(NOT BUILD_FOR_CONDA)
install(TARGETS nggui ${NG_INSTALL_DIR})
@ -49,7 +48,7 @@ if(USE_PYTHON)
if(USE_GUI)
add_library(ngguipy SHARED ngguipy.cpp)
target_link_libraries( ngguipy PUBLIC nglib nggui PRIVATE "$<BUILD_INTERFACE:netgen_python>" )
target_link_libraries( ngguipy PUBLIC nglib nggui PRIVATE "$<BUILD_INTERFACE:netgen_python>" $<BUILD_INTERFACE:netgen_gui>)
if(APPLE)
set_target_properties( ngguipy PROPERTIES SUFFIX ".so")
elseif(WIN32)

View File

@ -11,18 +11,9 @@ else(WIN32)
endif(WIN32)
add_library(togl ${TOGL_LIBRARY_TYPE} togl.c toglProcAddr.c toglStubInit.c)
if(WIN32)
target_compile_definitions(togl PUBLIC -DTOGL_WGL)
else(WIN32)
if(APPLE)
target_compile_definitions(togl PUBLIC -DTOGL_NSOPENGL)
else(APPLE)
target_compile_definitions(togl PUBLIC -DTOGL_X11)
endif(APPLE)
endif(WIN32)
target_link_libraries(togl PUBLIC ${TCL_STUB_LIBRARY} ${TK_STUB_LIBRARY})
target_link_libraries( togl PUBLIC $<BUILD_INTERFACE:netgen_gui>)
target_compile_definitions(togl PRIVATE -DBUILD_togl=1 -DSTDC_HEADERS=1 -DUSE_TCL_STUBS=1 -DUSE_TK_STUBS=1)
target_compile_definitions(togl PRIVATE -DBUILD_togl=1 -DSTDC_HEADERS=1)
if(WIN32)
target_compile_definitions(togl PRIVATE -DUNICODE -D_UNICODE -DTOGL_USE_FONTS=0 -DSTDC_HEADER)