@@ -75,8 +75,74 @@ endif ("${CMAKE_SYSTEM}" MATCHES ".*OpenBSD.*")
7575# Set up various relative path variables and build output directories
7676include (Path_Setup )
7777
78- # testing and compilation options, build output dirs, install dirs, uninstall, package creation, etc
79- include (${SC_CMAKE_DIR} /SC_Build_opts.cmake )
78+ #---------------------------------------------------------------------
79+ # The following logic is what allows binaries to run successfully in
80+ # the build directory AND install directory. Thanks to plplot for
81+ # identifying the necessity of setting CMAKE_INSTALL_NAME_DIR on OSX.
82+ # Documentation of these options is available at
83+ # http://www.cmake.org/Wiki/CMake_RPATH_handling
84+
85+ # use, i.e. don't skip the full RPATH for the build tree
86+ if (NOT DEFINED CMAKE_SKIP_BUILD_RPATH )
87+ set (CMAKE_SKIP_BUILD_RPATH FALSE )
88+ endif ()
89+
90+ # when building, don't use the install RPATH already
91+ # (but later on when installing)
92+ if (NOT DEFINED CMAKE_BUILD_WITH_INSTALL_RPATH )
93+ set (CMAKE_BUILD_WITH_INSTALL_RPATH FALSE )
94+ endif ()
95+
96+ # the RPATH/INSTALL_NAME_DIR to be used when installing
97+ if (NOT APPLE )
98+ if (NOT DEFINED CMAKE_INSTALL_RPATH )
99+ set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX} /lib:\$ ORIGIN/../lib" )
100+ endif ()
101+ endif (NOT APPLE )
102+ # On OSX, we need to set INSTALL_NAME_DIR instead of RPATH
103+ # http://www.cmake.org/cmake/help/cmake-2-8-docs.html#variable:CMAKE_INSTALL_NAME_DIR
104+ if (NOT DEFINED CMAKE_INSTALL_NAME_DIR )
105+ set (CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX} /lib" )
106+ endif ()
107+
108+ # add the automatically determined parts of the RPATH which point to
109+ # directories outside the build tree to the install RPATH
110+ if (NOT DEFINED CMAKE_INSTALL_RPATH_USE_LINK_PATH )
111+ set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE )
112+ endif ()
113+
114+
115+ #---------------------------------------------------------------------
116+ # Build options
117+ option (BUILD_SHARED_LIBS "Build shared libraries" ON )
118+ option (BUILD_STATIC_LIBS "Build static libraries" OFF )
119+
120+ option (SC_PYTHON_GENERATOR "Compile exp2python" ON )
121+ option (SC_CPP_GENERATOR "Compile exp2cxx" ON )
122+
123+ option (SC_MEMMGR_ENABLE_CHECKS "Enable sc_memmgr's memory leak detection" OFF )
124+ option (SC_TRACE_FPRINTF "Enable extra comments in generated code so the code's source in exp2cxx may be located" OFF )
125+
126+ option (SC_ENABLE_COVERAGE "Enable code coverage test" OFF )
127+ if (SC_ENABLE_COVERAGE AND ${CMAKE_C_COMPILER_ID} STREQUAL "GNU" )
128+ set (CMAKE_C_FLAGS_DEBUG "-O0 -g -fprofile-arcs -ftest-coverage" CACHE STRING "Extra compile flags required by code coverage" FORCE )
129+ set (CMAKE_CXX_FLAGS_DEBUG "-O0 -g -fprofile-arcs -ftest-coverage" CACHE STRING "Extra compile flags required by code coverage" FORCE )
130+ set (CMAKE_MODULE_LINKER_FLAGS_DEBUG "-fprofile-arcs -ftest-coverage" CACHE STRING "Extra linker flags required by code coverage" FORCE )
131+ endif (SC_ENABLE_COVERAGE AND ${CMAKE_C_COMPILER_ID} STREQUAL "GNU" )
132+
133+ option (SC_ENABLE_TESTING "Enable unittesting framework" OFF )
134+ if (SC_ENABLE_TESTING)
135+ if (NOT DEFINED SC_BUILD_SCHEMAS)
136+ set (SC_BUILD_SCHEMAS "ALL" ) #test all schemas, unless otherwise specified
137+ endif ()
138+ include (CTest )
139+ endif (SC_ENABLE_TESTING )
140+
141+ # TODO - BRL-CAD is the only known user of this option, and it will be
142+ # transitioning to a new setup that won't need it - once that's done,
143+ # we should just remove this option.
144+ option (SC_SKIP_EXEC_INSTALL "Skip installing executables" OFF )
145+ mark_as_advanced (SC_SKIP_EXEC_INSTALL )
80146
81147# SC_ADDEXEC and SC_ADDLIB macros, dllimport/export, etc
82148include (SC_Targets )
@@ -90,6 +156,9 @@ include(SC_Locale)
90156# logic related to regenerating the lexer and parser source code
91157include (SC_Regenerate )
92158
159+ # create config headers sc_cf.h and sc_version_string.h
160+ include (SC_Config_Headers )
161+
93162if (NOT DEFINED SC_SDAI_ADDITIONAL_EXES_SRCS)
94163 set (SC_SDAI_ADDITIONAL_EXES_SRCS "" CACHE STRING "Source files for additional executables to be linked with SDAI libs" )
95164endif (NOT DEFINED SC_SDAI_ADDITIONAL_EXES_SRCS )
@@ -145,13 +214,19 @@ if(SC_ENABLE_TESTING)
145214endif (SC_ENABLE_TESTING )
146215add_subdirectory (doc )
147216
148- # 'make core' builds everything that isn't generated. for devs.
149- add_custom_target (core )
150- if (BUILD_SHARED_LIBS )
151- add_dependencies (core stepdai stepeditor exp2cxx check-express )
152- else ()
153- add_dependencies (core stepdai-static stepeditor-static exp2cxx check-express )
154- endif ()
217+ if (NOT SC_IS_SUBBUILD)
218+ #-----------------------------------------------------------------------------
219+ # SC Packaging
220+ # $make package
221+ set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "STEPcode" )
222+ set (CPACK_SET_DESTDIR "ON" )
223+ set (CPACK_PACKAGE_VERSION_MAJOR ${SC_VERSION_MAJOR} )
224+ set (CPACK_PACKAGE_VERSION_MINOR ${SC_VERSION_MINOR} )
225+ set (CPACK_PACKAGE_NAME SC)
226+ set (CPACK_PACKAGE_CONTACT "SC Developers <scl-dev@googlegroups.com>" )
227+ include (CPack )
228+ endif (NOT SC_IS_SUBBUILD )
229+
155230
156231# CONFIG_END_MESSAGES - list of messages to be printed after everything else is done.
157232# THIS MUST BE LAST to ensure that they are visible to the user without scrolling.
0 commit comments