update scl_utils macros for apple flags and for windows dllimport/dllexport

This commit is contained in:
Mark Pictor
2012-05-05 11:06:54 -04:00
parent b72eea6fac
commit 7be54f3fec
10 changed files with 122 additions and 182 deletions
+93 -54
View File
@@ -1,75 +1,114 @@
# Will need windows logic someday, even though it doesn't work yet, so go ahead
# and add the DLL_DEFINE macro
MACRO(DLL_DEFINE libname)
IF(MSVC)
STRING(REGEX REPLACE "lib" "" LOWERCORE "${libname}")
STRING(TOUPPER ${LOWERCORE} UPPER_CORE)
add_definitions("-D${UPPER_CORE}_EXPORT_DLL")
ENDIF(MSVC)
ENDMACRO()
MACRO(DEFINE_DLL_EXPORTS libname)
IF( MSVC OR BORLAND )
if( ${libname} MATCHES "SDAI_.*" )
set( export "SCL_SCHEMA_DLL_EXPORTS" )
else()
STRING(REGEX REPLACE "lib" "" shortname "${libname}")
STRING(REGEX REPLACE "step" "" LOWERCORE "${shortname}")
STRING(TOUPPER ${LOWERCORE} UPPER_CORE)
set( export "SCL_${UPPER_CORE}_DLL_EXPORTS" )
endif()
get_target_property(defs ${libname} COMPILE_DEFINITIONS )
if( defs ) #if no properties, ${defs} will be defs-NOTFOUND which CMake interprets as false
set( defs "${defs};${export}")
else( defs )
set( defs "${export}")
endif( defs )
set_target_properties(${libname} PROPERTIES COMPILE_DEFINITIONS "${defs}" )
ENDIF( MSVC OR BORLAND )
ENDMACRO(DEFINE_DLL_EXPORTS libname)
MACRO( DEFINE_DLL_IMPORTS tgt libs )
IF( MSVC OR BORLAND )
get_target_property(defs ${tgt} COMPILE_DEFINITIONS )
if( NOT defs ) #if no properties, ${defs} will be defs-NOTFOUND which CMake interprets as false
set( defs "")
endif( NOT defs )
foreach( lib ${libs} )
STRING(REGEX REPLACE "lib" "" shortname "${lib}")
STRING(REGEX REPLACE "step" "" LOWERCORE "${shortname}")
STRING(TOUPPER ${LOWERCORE} UPPER_CORE)
list( APPEND defs "SCL_${UPPER_CORE}_DLL_IMPORTS" )
endforeach( lib ${libs} )
if( DEFINED defs )
if( defs )
set_target_properties( ${tgt} PROPERTIES COMPILE_DEFINITIONS "${defs}" )
endif( defs )
endif( DEFINED defs )
ENDIF( MSVC OR BORLAND )
ENDMACRO( DEFINE_DLL_IMPORTS tgt libs )
MACRO(SCL_ADDEXEC execname srcs libs)
STRING(REGEX REPLACE " " ";" srcslist "${srcs}")
STRING(REGEX REPLACE " " ";" libslist "${libs}")
add_executable(${execname} ${srcslist})
target_link_libraries(${execname} ${libslist})
INSTALL(TARGETS ${execname} DESTINATION bin)
# Enable extra compiler flags if local executables and/or global options dictate
SET(LOCAL_COMPILE_FLAGS "")
FOREACH(extraarg ${ARGN})
IF(${extraarg} MATCHES "STRICT" AND SCL-ENABLE_STRICT)
SET(LOCAL_COMPILE_FLAGS "${LOCAL_COMPILE_FLAGS} ${STRICT_FLAGS}")
ENDIF(${extraarg} MATCHES "STRICT" AND SCL-ENABLE_STRICT)
ENDFOREACH(extraarg ${ARGN})
IF(LOCAL_COMPILE_FLAGS)
SET_TARGET_PROPERTIES(${execname} PROPERTIES COMPILE_FLAGS ${LOCAL_COMPILE_FLAGS})
ENDIF(LOCAL_COMPILE_FLAGS)
STRING(REGEX REPLACE " " ";" srcslist "${srcs}")
STRING(REGEX REPLACE " " ";" libslist "${libs}")
add_executable(${execname} ${srcslist})
target_link_libraries(${execname} ${libslist})
DEFINE_DLL_IMPORTS(${execname} "${libslist}") #add import definitions for all libs that the executable is linked to
INSTALL(TARGETS ${execname} DESTINATION bin)
# Enable extra compiler flags if local executables and/or global options dictate
SET(LOCAL_COMPILE_FLAGS "")
FOREACH(extraarg ${ARGN})
IF(${extraarg} MATCHES "STRICT" AND SCL-ENABLE_STRICT)
SET(LOCAL_COMPILE_FLAGS "${LOCAL_COMPILE_FLAGS} ${STRICT_FLAGS}")
ENDIF(${extraarg} MATCHES "STRICT" AND SCL-ENABLE_STRICT)
ENDFOREACH(extraarg ${ARGN})
IF(LOCAL_COMPILE_FLAGS)
SET_TARGET_PROPERTIES(${execname} PROPERTIES COMPILE_FLAGS ${LOCAL_COMPILE_FLAGS})
ENDIF(LOCAL_COMPILE_FLAGS)
ENDMACRO(SCL_ADDEXEC execname srcs libs)
MACRO(SCL_ADDLIB libname srcs libs)
STRING(REGEX REPLACE " " ";" srcslist "${srcs}")
STRING(REGEX REPLACE " " ";" libslist1 "${libs}")
STRING(REGEX REPLACE "-framework;" "-framework " libslist "${libslist1}")
DLL_DEFINE(${libname})
IF(SCL_BUILD_SHARED_LIBS)
add_library(${libname} SHARED ${srcslist})
if(NOT ${libs} MATCHES "NONE")
target_link_libraries(${libname} ${libslist})
endif(NOT ${libs} MATCHES "NONE")
SET_TARGET_PROPERTIES(${libname} PROPERTIES VERSION ${SCL_ABI_VERSION} SOVERSION ${SCL_ABI_SOVERSION} )
INSTALL(TARGETS ${libname} DESTINATION lib)
add_library(${libname} SHARED ${srcslist})
DEFINE_DLL_EXPORTS(${libname})
if(NOT ${libs} MATCHES "NONE")
target_link_libraries(${libname} ${libslist})
DEFINE_DLL_IMPORTS(${libname} "${libslist}" )
endif(NOT ${libs} MATCHES "NONE")
SET_TARGET_PROPERTIES(${libname} PROPERTIES VERSION ${SCL_ABI_VERSION} SOVERSION ${SCL_ABI_SOVERSION} )
INSTALL(TARGETS ${libname} DESTINATION lib)
if(APPLE)
set_target_properties(${libname} PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress")
endif(APPLE)
ENDIF(SCL_BUILD_SHARED_LIBS)
IF(SCL_BUILD_STATIC_LIBS AND NOT MSVC)
add_library(${libname}-static STATIC ${srcslist})
if(NOT ${libs} MATCHES "NONE")
target_link_libraries(${libname}-static ${libslist})
endif(NOT ${libs} MATCHES "NONE")
IF(NOT WIN32)
SET_TARGET_PROPERTIES(${libname}-static PROPERTIES OUTPUT_NAME "${libname}")
ENDIF(NOT WIN32)
IF(WIN32)
# We need the lib prefix on win32, so add it even if our add_library
# wrapper function has removed it due to the target name - see
# http://www.cmake.org/Wiki/CMake_FAQ#How_do_I_make_my_shared_and_static_libraries_have_the_same_root_name.2C_but_different_suffixes.3F
SET_TARGET_PROPERTIES(${libname}-static PROPERTIES PREFIX "lib")
ENDIF(WIN32)
INSTALL(TARGETS ${libname}-static DESTINATION lib)
add_library(${libname}-static STATIC ${srcslist})
DEFINE_DLL_EXPORTS(${libname}-static)
if(NOT ${libs} MATCHES "NONE")
target_link_libraries(${libname}-static "${libslist}")
DEFINE_DLL_IMPORTS(${libname}-static ${libslist} )
endif(NOT ${libs} MATCHES "NONE")
IF(NOT WIN32)
SET_TARGET_PROPERTIES(${libname}-static PROPERTIES OUTPUT_NAME "${libname}")
ENDIF(NOT WIN32)
IF(WIN32)
# We need the lib prefix on win32, so add it even if our add_library
# wrapper function has removed it due to the target name - see
# http://www.cmake.org/Wiki/CMake_FAQ#How_do_I_make_my_shared_and_static_libraries_have_the_same_root_name.2C_but_different_suffixes.3F
SET_TARGET_PROPERTIES(${libname}-static PROPERTIES PREFIX "lib")
ENDIF(WIN32)
INSTALL(TARGETS ${libname}-static DESTINATION lib)
if(APPLE)
set_target_properties(${libname}-static PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress")
endif(APPLE)
ENDIF(SCL_BUILD_STATIC_LIBS AND NOT MSVC)
# Enable extra compiler flags if local libraries and/or global options dictate
SET(LOCAL_COMPILE_FLAGS "")
FOREACH(extraarg ${ARGN})
IF(${extraarg} MATCHES "STRICT" AND SCL-ENABLE_STRICT)
SET(LOCAL_COMPILE_FLAGS "${LOCAL_COMPILE_FLAGS} ${STRICT_FLAGS}")
ENDIF(${extraarg} MATCHES "STRICT" AND SCL-ENABLE_STRICT)
IF(${extraarg} MATCHES "STRICT" AND SCL-ENABLE_STRICT)
SET(LOCAL_COMPILE_FLAGS "${LOCAL_COMPILE_FLAGS} ${STRICT_FLAGS}")
ENDIF(${extraarg} MATCHES "STRICT" AND SCL-ENABLE_STRICT)
ENDFOREACH(extraarg ${ARGN})
IF(LOCAL_COMPILE_FLAGS)
IF(BUILD_SHARED_LIBS)
SET_TARGET_PROPERTIES(${libname} PROPERTIES COMPILE_FLAGS ${LOCAL_COMPILE_FLAGS})
ENDIF(BUILD_SHARED_LIBS)
IF(BUILD_STATIC_LIBS AND NOT MSVC)
SET_TARGET_PROPERTIES(${libname}-static PROPERTIES COMPILE_FLAGS ${LOCAL_COMPILE_FLAGS})
ENDIF(BUILD_STATIC_LIBS AND NOT MSVC)
IF(BUILD_SHARED_LIBS)
SET_TARGET_PROPERTIES(${libname} PROPERTIES COMPILE_FLAGS ${LOCAL_COMPILE_FLAGS})
ENDIF(BUILD_SHARED_LIBS)
IF(BUILD_STATIC_LIBS AND NOT MSVC)
SET_TARGET_PROPERTIES(${libname}-static PROPERTIES COMPILE_FLAGS ${LOCAL_COMPILE_FLAGS})
ENDIF(BUILD_STATIC_LIBS AND NOT MSVC)
ENDIF(LOCAL_COMPILE_FLAGS)
ENDMACRO(SCL_ADDLIB libname srcs libs)
+3 -18
View File
@@ -63,23 +63,10 @@ FUNCTION(BUILD_A_SCHEMA SCHEMA_FILE)
WORKING_DIRECTORY ${SCHEMA_OUTPUT_DIR}
COMMENT "Running fedex_plus for ${SCHEMA_SHORT_NAME}..."
VERBATIM )
if(MSVC OR BORLAND)
add_definitions( -DSCL_SCHEMA_DLL_EXPORTS )
add_definitions( -DSCL_BASE_DLL_IMPORTS )
add_definitions( -DSCL_EXPRESS_DLL_IMPORTS )
add_definitions( -DSCL_UTILS_DLL_IMPORTS )
add_definitions( -DSCL_DAI_DLL_IMPORTS )
add_definitions( -DSCL_CORE_DLL_IMPORTS )
add_definitions( -DSCL_EDITOR_DLL_IMPORTS )
endif()
add_library( ${PROJECT_NAME} SHARED ${FEDEX_OUT} )
target_link_libraries(${PROJECT_NAME} stepdai stepcore express stepeditor steputils base )
SCL_ADDLIB( ${PROJECT_NAME} "${FEDEX_OUT}" "stepdai stepcore express stepeditor steputils base" )
add_dependencies( ${PROJECT_NAME} generate_cpp_${SCHEMA_SHORT_NAME} )
set_target_properties( ${PROJECT_NAME} PROPERTIES COMPILE_FLAGS
${${PROJECT_NAME}_COMPILE_FLAGS} )
if(APPLE)
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress")
endif(APPLE)
TESTABLE_TARGET( ${PROJECT_NAME} )
add_test( NAME generate_cpp_${SCHEMA_SHORT_NAME}
@@ -98,12 +85,10 @@ FUNCTION(BUILD_A_SCHEMA SCHEMA_FILE)
set_tests_properties( build_cpp_${PROJECT_NAME} PROPERTIES DEPENDS generate_cpp_${SCHEMA_SHORT_NAME} LABELS cpp_schema_build )
if(MSVC OR BORLAND)
add_executable( p21read_${PROJECT_NAME} ${SCL_SOURCE_DIR}/src/test/p21read/p21read.cc ${SCL_SOURCE_DIR}/src/fedex_plus/xgetopt.cc )
else()
add_executable( p21read_${PROJECT_NAME} ${SCL_SOURCE_DIR}/src/test/p21read/p21read.cc )
set( WIN_EXTRA_SRCS ${SCL_SOURCE_DIR}/src/fedex_plus/xgetopt.cc )
endif()
SCL_ADDEXEC( p21read_${PROJECT_NAME} "${SCL_SOURCE_DIR}/src/test/p21read/p21read.cc ${WIN_EXTRA_SRCS}" "${PROJECT_NAME}" )
add_dependencies( p21read_${PROJECT_NAME} version_string )
target_link_libraries( p21read_${PROJECT_NAME} ${PROJECT_NAME} )
set_target_properties( p21read_${PROJECT_NAME} PROPERTIES COMPILE_FLAGS
${${PROJECT_NAME}_COMPILE_FLAGS} )
TESTABLE_TARGET( p21read_${PROJECT_NAME} )
+6 -18
View File
@@ -8,9 +8,9 @@ set(LIBSTEPDAI_SRCS
sdaiEntity_extent_set.cc
sdaiModel_contents.cc
sdaiModel_contents_list.cc
sdaiEnum.cc
sdaiString.cc
sdaiBinary.cc
sdaiEnum.cc
sdaiString.cc
sdaiBinary.cc
)
SET(LIBSTEPDAI_PRIVATE_HDRS
@@ -23,17 +23,11 @@ SET(LIBSTEPDAI_PRIVATE_HDRS
sdaiObject.h
sdaiSession_instance.h
StrUtil.hh
sdaiEnum.h
sdaiString.h
sdaiBinary.h
sdaiEnum.h
sdaiString.h
sdaiBinary.h
)
IF(MSVC OR BORLAND)
add_definitions( -DSCL_DAI_DLL_EXPORTS )
add_definitions( -DSCL_BASE_DLL_IMPORTS )
add_definitions( -DSCL_UTILS_DLL_IMPORTS )
ENDIF()
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${SCL_SOURCE_DIR}/src/base
@@ -42,9 +36,3 @@ include_directories(
)
SCL_ADDLIB(stepdai "${LIBSTEPDAI_SRCS}" "steputils base")
if(APPLE)
if(SCL_BUILD_SHARED_LIBS)
set_target_properties(stepdai PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress")
endif(SCL_BUILD_SHARED_LIBS)
endif(APPLE)
-14
View File
@@ -41,18 +41,4 @@ include_directories(
${SCL_SOURCE_DIR}/src/clutils
)
if(MSVC OR BORLAND)
add_definitions( -DSCL_EDITOR_DLL_EXPORTS )
add_definitions( -DSCL_BASE_DLL_IMPORTS )
add_definitions( -DSCL_CORE_DLL_IMPORTS )
add_definitions( -DSCL_DAI_DLL_IMPORTS )
add_definitions( -DSCL_UTILS_DLL_IMPORTS )
endif()
SCL_ADDLIB(stepeditor "${LIBSTEPEDITOR_SRCS}" "stepcore stepdai steputils base")
if(APPLE)
if(SCL_BUILD_SHARED_LIBS)
set_target_properties(stepeditor PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress")
endif(SCL_BUILD_SHARED_LIBS)
endif(APPLE)
+14 -27
View File
@@ -28,31 +28,23 @@ set(LIBSTEPCORE_SRCS
)
if(MINGW)
set(LIBDEPEND_SRCS
${SCL_SOURCE_DIR}/src/cleditor/instmgr.cc
${SCL_SOURCE_DIR}/src/cleditor/mgrnode.cc
${SCL_SOURCE_DIR}/src/cleditor/dispnode.cc
${SCL_SOURCE_DIR}/src/cleditor/mgrnodearray.cc
${SCL_SOURCE_DIR}/src/cleditor/needFunc.cc
)
set(LIBDEPEND_SRCS
${SCL_SOURCE_DIR}/src/cleditor/instmgr.cc
${SCL_SOURCE_DIR}/src/cleditor/mgrnode.cc
${SCL_SOURCE_DIR}/src/cleditor/dispnode.cc
${SCL_SOURCE_DIR}/src/cleditor/mgrnodearray.cc
${SCL_SOURCE_DIR}/src/cleditor/needFunc.cc
)
endif(MINGW)
if(MSVC OR BORLAND)
set(LIBDEPEND_SRCS
${SCL_SOURCE_DIR}/src/cleditor/instmgr.cc
${SCL_SOURCE_DIR}/src/cleditor/mgrnode.cc
${SCL_SOURCE_DIR}/src/cleditor/dispnode.cc
${SCL_SOURCE_DIR}/src/cleditor/mgrnodearray.cc
${SCL_SOURCE_DIR}/src/cleditor/needFunc.cc
)
endif()
if(MSVC OR BORLAND)
add_definitions( -DSCL_CORE_DLL_EXPORTS )
add_definitions( -DSCL_BASE_DLL_IMPORTS )
add_definitions( -DSCL_EXPRESS_DLL_IMPORTS )
add_definitions( -DSCL_UTILS_DLL_IMPORTS )
add_definitions( -DSCL_DAI_DLL_IMPORTS )
set(LIBDEPEND_SRCS
${SCL_SOURCE_DIR}/src/cleditor/instmgr.cc
${SCL_SOURCE_DIR}/src/cleditor/mgrnode.cc
${SCL_SOURCE_DIR}/src/cleditor/dispnode.cc
${SCL_SOURCE_DIR}/src/cleditor/mgrnodearray.cc
${SCL_SOURCE_DIR}/src/cleditor/needFunc.cc
)
endif()
SET(LIBSTEPCORE_PRIVATE_HDRS
@@ -86,8 +78,3 @@ include_directories(
)
SCL_ADDLIB(stepcore "${LIBSTEPCORE_SRCS} ${LIBDEPEND_SRCS}" "express steputils stepdai base")
if(APPLE)
if(SCL_BUILD_SHARED_LIBS)
set_target_properties(stepcore PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress")
endif(SCL_BUILD_SHARED_LIBS)
endif(APPLE)
+1 -16
View File
@@ -28,23 +28,8 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
)
if (MSVC OR BORLAND)
add_definitions( -DSCL_BASE_DLL_IMPORTS )
add_definitions( -DSCL_UTILS_DLL_EXPORTS )
endif()
SCL_ADDLIB(steputils "${LIBSTEPUTILS_SRCS}" "base")
IF(MINGW)
IF(MINGW OR MSVC OR BORLAND)
TARGET_LINK_LIBRARIES(steputils shlwapi.lib)
ENDIF(MINGW)
IF(MSVC OR BORLAND)
TARGET_LINK_LIBRARIES(steputils shlwapi.lib)
ENDIF()
if(APPLE)
if(SCL_BUILD_SHARED_LIBS)
set_target_properties(steputils PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress")
endif(SCL_BUILD_SHARED_LIBS)
endif(APPLE)
+2 -12
View File
@@ -10,17 +10,12 @@ set(LIBEXPPP_SOURCES
include_directories(
${SCL_SOURCE_DIR}/include
${SCL_SOURCE_DIR}/include/exppp
${SCL_SOURCE_DIR}/src/base
${SCL_SOURCE_DIR}/src/base
)
if(MSVC OR BORLAND)
add_definitions( -DSCL_EXPPP_DLL_EXPORTS )
add_definitions( -DSCL_EXPRESS_DLL_IMPORTS )
add_definitions( -DSCL_BASE_DLL_IMPORTS )
endif()
if(BORLAND)
add_definitions( -D__STDC__ )
add_definitions( -D__STDC__ )
endif()
SCL_ADDLIB(libexppp "${LIBEXPPP_SOURCES}" "express base")
@@ -30,8 +25,3 @@ endif(SCL_BUILD_SHARED_LIBS)
#SCL_ADDEXEC(exppp "${EXPPP_SOURCES}" "libexppp express")
if(APPLE)
if(SCL_BUILD_SHARED_LIBS)
set_target_properties(libexppp PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress")
endif(SCL_BUILD_SHARED_LIBS)
endif(APPLE)
+1 -13
View File
@@ -80,21 +80,9 @@ add_definitions( -DYY_NO_UNISTD_H )
endif()
if(BORLAND)
add_definitions( -D__STDC__ )
add_definitions( -DSCL_BASE_DLL_IMPORTS )
add_definitions( -D__STDC__ )
endif()
SCL_ADDLIB(express "${EXPRESS_SOURCES}" "base")
if(APPLE)
if(SCL_BUILD_SHARED_LIBS)
set_target_properties(express PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress")
endif(SCL_BUILD_SHARED_LIBS)
endif(APPLE)
SCL_ADDEXEC("check-express" "${CHECK_EXPRESS_SOURCES} ${CHECK_EXPRESS_EXTRA_SOURCES}" express)
if(MSVC OR BORLAND)
set_target_properties(express PROPERTIES COMPILE_DEFINITIONS SCL_EXPRESS_DLL_EXPORTS)
set_target_properties("check-express" PROPERTIES COMPILE_DEFINITIONS SCL_EXPRESS_DLL_IMPORTS)
endif()
+1 -6
View File
@@ -29,12 +29,7 @@ include_directories(
)
IF(MSVC OR BORLAND)
set(fedex_plus_EXTRA_SOURCES
xgetopt.cc
)
add_definitions( -DSCL_EXPRESS_DLL_IMPORTS )
add_definitions( -DSCL_EXPPP_DLL_IMPORTS )
add_definitions( -DSCL_BASE_DLL_IMPORTS )
set(fedex_plus_EXTRA_SOURCES xgetopt.cc )
ENDIF()
IF ("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
+1 -4
View File
@@ -4,7 +4,7 @@ include_directories(
${SCL_SOURCE_DIR}/include
${SCL_SOURCE_DIR}/include/exppp
${SCL_SOURCE_DIR}/include/express
${SCL_SOURCE_DIR}/src/base
${SCL_SOURCE_DIR}/src/base
${SCL_SOURCE_DIR}/src/fedex_plus
)
@@ -14,9 +14,6 @@ IF(MSVC)
set(fedex_plus_MSVC_SOURCES
${SCL_SOURCE_DIR}/src/fedex_plus/xgetopt.cc
)
add_definitions( -DSCL_BASE_DLL_IMPORTS )
add_definitions( -DSCL_EXPRESS_DLL_IMPORTS )
add_definitions( -DSCL_EXPPP_DLL_IMPORTS )
ENDIF(MSVC)
set(fedex_python_SOURCES